[C++] Warning C4812: obsolete declaration style

0

Witam. Mam program który bez zarzutu działa kompilowany G++ pod linuksem ale daje rady go przenieść na Windowsa pod Visuala.

Mam klasę:

 

namespace cvector{
	template <typename T = int>
           class Cvector
	{	
		void InsertElement( Cvector<T> *&Element, T value); 
	}

           template <typename T> 
           void Cvector<T>::InsertElement(Cvector<T>::Cvector<T> *&Element, T value)
          { ... }
}

I otrzymuje:
warning C4812: obsolete declaration style: please use 'cvector::Cvector<T>::Cvector' instead

Jeżeli zmienie na:

 

namespace cvector{
	template <typename T = int>
           class Cvector
	{	
		void InsertElement( Cvector<T> *&Element, T value); 
	}

           template <typename T> 
           void Cvector<T>::InsertElement(Cvector<T>::Cvector *&Element, T value)
           { ... }
}

To otrzymuje:

error C2065: 'Element' : undeclared identifier
error C2277: 'cvector::Cvector<T>::Cvector' : cannot take address of this member function

Próbuje wszystkie kombinacje i zawsze mam błędy. Jak to prawidłowo zapisać? Z góry dziękuje za pomoc.

0

Próbuje wszystkie kombinacje i

Nie próbowałeś najbardziej oczywistej.
W deklaracji parametr Element jest typu Cvector<‌T‌> *&

W definicji za to nie wiedzieć czemu nagle jest to <code noframe>Cvector<‌T‌>::Cvector<‌T‌> *&

Teraz znajdź jedną różnicę ;-)

0

No właśnie nie widzę różnicy :( Pod G++ tylko taką wersję mi kompilowało :(

0

nie widzisz różnicy między "Cvector<‌T‌> *&", a "Cvector<‌T‌>::Cvector<‌T‌> *&" ? :|

0

Czyli jak ma to przekazać?

template <typename T> void Cvector<T>::InsertElement(Cvector *&Element, T value)

warning C4812: obsolete declaration style: please use 'cvector::Cvector<T>::Cvector' instead

template <typename T> void Cvector<T>::InsertElement(Cvector<T> *&Element, T value)

warning C4812: obsolete declaration style: please use 'cvector::Cvector<T>::Cvector' instead

template <typename T> void Cvector<T>::InsertElement(Cvector::Cvector<T> *&Element, T value)
warning C4812: obsolete declaration style: please use 'cvector::Cvector<T>::Cvector' instead

error C2065: 'Element' : undeclared identifier
template <typename T> void Cvector<T>::InsertElement(Cvector<T>::Cvector *&Element, T value)
error C2065: 'Element' : undeclared identifier
error C2277: 'cvector::Cvector<T>::Cvector' : cannot take address of this member function

Jeśli popełniam jakiś głupi błąd to wskażcie mi go bo ja już nie mam siły na tego visuala :(

0

Chyba mu chodzi o: Cvector<‌T‌>::

0

Czyli jak ma to przekazać?

Dokładnie tak jak jest w deklaracji.

0
template <typename T> void Cvector<T>::InsertElement(Cvector<T> *&Element, T value)

warning C4812: obsolete declaration style: please use 'cvector::Cvector<T>::Cvector' instead

Tak? Nie rozumiem gdzie popełniam błąd.

0
  1. jaka wersja visuala?
  2. daj kod który rzeczywiście kompilujesz, bo w tym co dałeś u góry nawet średnika po klasie brakuje.
  3. to się kompiluje bez problemu
namespace cvector{
        template <typename T = int>
           class Cvector
        {        
                void InsertElement( Cvector<T> *&Element, T value); 
        };

           template <typename T> 
           void Cvector<T>::InsertElement(Cvector<T> *&Element, T value)
          {}
}


int main()
{
}
0

Rozchodzi się chyba o to http://msdn.microsoft.com/en-us/library/h0h57k4a(v=VS.90).aspx

Kompiluje z /W1 /c ale nadal te same błędy. Używam Visuala 2008 Express Edition.

0

Kompilujesz CO?

1 użytkowników online, w tym zalogowanych: 0, gości: 1