Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2008, 01:31 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default C++ question

I have three C++ files,like follows:
/*Test.h*/
Code:
#include <iostream.h>
class Test{
public:
   Test();
};
/*Test.cpp*/
Code:
#include "Test.h"
Test::Test(){
   cout<<"Test called";
}
/*a.cpp*/
Code:
#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 With Quote
  #2 (permalink)  
Old July 3rd, 2008, 07:02 AM
Registered User
 
Join Date: Jul 2008
Location: Cologne, , Germany.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question maheshraju ASP.NET 2.0 Basics 3 March 13th, 2008 08:54 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
Question? Calibus Classic ASP Databases 8 August 6th, 2004 08:25 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM



All times are GMT -4. The time now is 09:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.