Error while putting classes in separate files

+2 Bijay Das · April 14, 2015
I'm trying to put my classes in separate files but I'm getting an error. I don't know why, I've watched the 15th c++ video several times and I've done exactly same the way but I'm facing the same prob. Can anyone please help me with this?

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Bijay Das · April 16, 2015
Which IDE should I use(xcode / clion / Visual Studio), I am using 32 bit Window 7 Home Premium, 3 GB RAM), core 2 duo processor? I saw the iTunes page in Wikipedia it says iTunes written in c++. Which IDE is used by the professionals? Do I need to purchase that? I live in Delhi, India. How much it will cost?
0 Brian Reed · April 15, 2015
Bijay,

I'm surely not one to suggest you should change from Code Blocks now (especially if its working for you).
However, is it working for you now?

There are no issues with code blocks that I'm aware of, no workarounds needed, I may have though so in the beginning, but not now. When I had these similar problems it was in not learning how to setup my projects properly. Sure, you can go out and find other compilers, but that's no assurance against you not have any issues with them either.
However, if you want to get more serious at building programs later, then ya, upgrade! A lot out there are free, I downloaded QT Creator and it seems to be pretty cool, I will start using when I build some real projects.

Cheers,
Brian 
0 Dol Lod · April 15, 2015
If you are planning to distribute the application, I would use CLION b/c it will help you actually catch errors.

If you're planning on just having a personal copy, use visual studio since it is easy to work with. 
0 Anthony Tremaglio · April 15, 2015
Bijay, apparently this is some sort of issue with code::blocks.  There is a workaround but not a fix.

After you create a class in a separate file, you have to save your project, close the project and reopen the project.  If you do that before trying to run the program you won't get that error.

Hope this helps.
0 Bijay Das · April 15, 2015
First of all thank you everyone for your answers.
Bucky uses code::blocks and this program worked perfectly. And you guys are telling me change my IDE, I will, but which should I use(xcode / clion / Visual Studio), I am using 32 bit  Window 7 Home Premium, 3 GB RAM), core 2 duo processor? I saw the iTunes page in Wikipedia it says iTunes written in c++. Which IDE is used by the professionals? Do I need to purchase that? I live in Delhi, India. How much it will cost?
0 Brian Reed · April 15, 2015
Hello All:

I think code blocks will work well for anyone going through the tutorials here8-)
However, I too have had issues the first time I started adding a class to a project:(
Don't try too long looking for the answers on the net, I spent hours with no good luck:angry:

Bijay Das:

Not sure of errors your getting, but it usually has to do with how the classes are created the first time. I kept using the same main class for all my testing of code, then when it came time to add classes that's when I had problems

I would recommend you start a new project from scratch. This should a least keep everything properly referenced together and under the same roof, so to speak.

Check out the C++ post
Need Help on C++ Tutorial 15 and 42 dated March 26 and follow Faha Sharapov lead on the second page.

Mahmoud Abdel Mon'em:
 "undefined references to 'WinMain@16'  This was my issue too!


Cheers,
Brian
0 Yazer Cha · April 15, 2015
I honestly have no idea what is going wrong.  I tried it in XCODE and it worked just fine for me.  I would recommend you download an IDE other than codeblocks.
0 Dol Lod · April 14, 2015
Which IDE are you using? That could possibly be the issue. I think this is CodeBlocks. Using CodeBlocks has never worked well for me. I would not recommend it as an IDE. 

Try running with CLION,Visual Studio or Xcode instead. CodeBlocks rarely works for me. Additionally, all three of these IDES are good for debugging code or pointing out problems if they exist.

I went through your syntax and cannot find the issue. Everything is defined clearly with correct syntax. 
+1 Bijay Das · April 14, 2015
/images/forum/upload/2015-04-14/ea94e45c3b364beeb2e95a2cebe6a093.JPG
+2 Yazer Cha · April 14, 2015
If you could put a sample of your code that would make it easier for us to determine what is wrong with your code.

I will try to help if you do that.

C++

129,974 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator