Thread: Another class problem

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    6

    Another class problem

    hi im writing code and i get another error saying need class/union/struct left of .(my class method).

    Yet i do Class ClassName();
    ClassName.myMethod();

    Yet if i use parameters instead it workds, only when there isnt any arguments. Isnt this wierd. I dunno if its msvc6 but im movin to vs.net2003 soon

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    http://www.parashift.com/c++-faq-lit....html#faq-10.2

    It's a strange "feature" of the language, but if your constructor has no parameters, then you shouldn't add parentheses or it will be interpreted as function instead of a variable declaration.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    6
    Thats retarded thank god its fixed in more oop languages i was so confused.

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Quote Originally Posted by thecneu
    Thats retarded thank god its fixed in more oop languages i was so confused.
    Indeed. That seems more like a bad habit that compilers have, though, as the context should uniquely indicate which one is meant.

    Sadly, GCC seems to have the same problem.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Thats retarded thank god its fixed in more oop languages i was so confused.
    Would that more oop language happen to be written in C++?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Quote Originally Posted by Zach L.
    Indeed. That seems more like a bad habit that compilers have, though, as the context should uniquely indicate which one is meant.

    Sadly, GCC seems to have the same problem.
    Technically it's part of the language standard, so it's not really the compilers' fault.

  7. #7
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    I didn't realize that, thanks.

    It still seems silly, though. The proper contexts for each are mutually exclusive...
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mesh Class Design problem
    By sarah22 in forum Game Programming
    Replies: 2
    Last Post: 05-20-2009, 04:52 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM