Subject: C++ question
Posted By: Edward King Post Date: 6/11/2008 1:31:15 AM
I have three C++ files,like follows:
/*Test.h*/
#include <iostream.h>
class Test{
public:
   Test();
};


/*Test.cpp*/
#include "Test.h"
Test::Test(){
   cout<<"Test called";
}


/*a.cpp*/
#include "Test.h"
int main(int argc, char* argv[])
{
   Test abc=new Test();
   return 0;
}


When I run a.cpp,it raise following error:
[C++ Error] a.cpp(4): E2034 Cannot convert 'Test *' to 'Test'

Why raise above error? How to correct my code?
Thanks

Reply By: Corax Reply Date: 7/3/2008 7:02:35 AM
As far as i Can tell the Problem is the Line :
  Test abc=new Test();
C++ expects a pointer when allocating memory via the new Operator.

To Create an instance of a Class
  Test abc;
should be enough.



Go to topic 72132

Return to index page 1