#### Archived

This topic is now archived and is closed to further replies.

# WTF is wrong with my VC?

This topic is 6001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I seem to have a major problem with my visual c++. I have a class which contains several functions. For arguments sake lets use this simple class:
  class testClass { // Construction public: testClass(){} ~testClass(){} // Some Functions public: int GetData() { return m_Data; } void DoStuff(); // Does some stuff // Some data protected: int m_Data; }; 
The problem is strange. I take the class (not this one, a much more complicated one) and go to use it.... include its header, yada yada yada.... do something like this:
  testClass aTester; aTester.DoStuff(); 
perfectly leagal right? OF COURSE IT IS! Well my compiler doesn''t like it! It gives me this error: error C2228: left of ''.Resize'' must have class/struct/union type where in my example Resize would be the DoStuff function. Ok so if thats not weird, copy paste the class into a different project, AND IT WORKS!! So i figure, hey maybe my project file is messed up. I back up the headers and source files. I delete the project folder, recreate and readd the files... SAME ERROR!! waht the heck is going on!!?!?! - SniperBoB

##### Share on other sites
Look for misspellings and misplaced semicolons/braces on preceding lines. They confuse the parser.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

##### Share on other sites
quote:
Ok so if thats not weird, copy paste the class into a different project, AND IT WORKS!!

I can''t figure it out. I''m about 10 seconds away from switching to Codewarrior, and 10 minutes away from switching to linux :-)

-SniperBoB

##### Share on other sites
quote:
Original post by SnprBoB86
I can''t figure it out. I''m about 10 seconds away from switching to Codewarrior, and 10 minutes away from switching to linux :-)

Not that that would help your situation at all. If you''re going to claim to switch software, you may want to do it for valid reasons . I''m very sure it''s something you''ve done wrong .

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
That was completely unrelated, I am having other Microsoft-Related problems.

but....

DOES ANYONE HAVE ANY CLUE WHAT THE PROBLEM COULD BE?!?

##### Share on other sites
i don't use VC++ but your error message looks like a variation of one that i have seen before (no promises)... are you sure you are doing this:
testClass aTester;aTester.DoStuff();

and not this:
testClass* aTester = new testClass();aTester.DoStuff();

?
that error occurs when you use . rather than -> (you need this arrow thing when accessing members of a class pointer, instead of the dot for accessing members of a class declared the regular way)...
you'd have to do it this way:
testClass* aTester = new testClass();aTester->DoStuff();

if not then sorry, i dunno... but i figured i'd give it a shot!

--- krez (krezisback@aol.com)

Edited by - krez on January 15, 2002 8:41:32 PM

##### Share on other sites
quote:

Ok so if thats not weird, copy paste the class into a different project, AND IT WORKS!! So i figure, hey maybe my project file is messed up. I back up the headers and source files. I delete the project folder, recreate and readd the files... SAME ERROR!!

This tells me that the way in which you're using the objects in the second project is not exactly the same as the way you're using it where you get the error. Like someone said, that error usually comes when you try to use .Method() where you really have a pointer, or ->Method() where you really have an object.

The project file is simply a make file. What you're getting is a parsing error, so the project is already compiling the correct code; there are no problems with the project file. If you're using precompiled headers there is a chance that the header hasn't recompiled and should, but if a rebuild-all doesn't do it then the error is in your code.

PS: blaming MS for everything may make you look cool to newbies, but it also makes you look like a newbie to old timers.

Edited by - Stoffel on January 15, 2002 8:51:58 PM

##### Share on other sites
quote:
Original post by Stoffel
PS: blaming MS for everything may make you look cool to newbies, but it also makes you look like a newbie to old timers.

Classic. Let''s print some T-Shirts.

##### Share on other sites
its absolutly not a pointer related problem... all instances are actual objects, but regaurdless i have tryed the -> also..... see the members aren''t even appearing in the class view

##### Share on other sites
OK, thinking it over and testing a few things out.... I am 100% positive it is a bug. If I create a class with all directly inlined functions in some projects it seems to work perfectly, but in others the above stated error occurs. Also in the faulting projects/builds/whatever the functions guilty of this error do not appear in the class view. I believe regaurdless of what the "old timers" say I believe it is most definitly Microsoft''s fault because on closer examination it seems to only happen to templated classes. We all know how badly MSVC++ cokes on templates.

So basicly what I''m trying to say is FLAME LESS.... HELP MORE. This is why I was reluctant to post my plee for help on a message board. Because almost every single thread turns into a breeding ground for little bastards who insist on insulting everyone with a question. I would like to publicly thank everyone who uses the fourms properly (specificly to you Oluseyi and krez in this thread).

Anyone else have any ideas on my problem?

SniperBoB

##### Share on other sites

This topic is 6001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999983
×