Thread: errors with class constructor

  1. #16
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    >>>newbox.name=name;


    you can't do this...
    Last edited by Betazep; 03-16-2002 at 08:37 PM.
    Blue

  2. #17
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    I gotta go... keep trying. Write a more simple class. Work your errors from there. The parenthesis go after the constructor and destructor. Your errors are elsewhere...
    Blue

  3. #18
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    sorry, i missed your code post. I still get the same error. this is ........ing me off so much!
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #19
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    you got that error with the code that I posted?

    someone more familiar with MSVC++ is going to have to help you.... I do not know why that would happen

    Prelude... got any ideas???
    Blue

  5. #20
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    well, I added a ; to the end of the class declaration, and now I still get that weird error! GAR!!!!!!!!!!!!!
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  6. #21
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    Code:
    class test
    {
       public:
           test();
           int a;
    };
    
    test::test()
    {
       a = 0;
    }
    
    int main()
    {
       test it;
       
       return 0;
    }
    so you tried just like that? This compiles absolutely fine for me.
    Blue

  7. #22
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    i just tried that exact code again. this time it works. maybe today is a better day. I will try my code.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  8. #23
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    My code still gives errors on the constructor. Same single error. Here's an update to my code:
    Last edited by neandrake; 03-17-2002 at 10:47 AM.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  9. #24
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    problem is not with the constructor, it's in the deconstructor. I commented out first the constructor and got errors. then i commented out just the deconstructor and it compiled fine.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  10. #25
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    const RIGHT=2;
    const LEFT=3;

    I bet you are getting errors here too.

    How does the compiler know they are ints or defines?
    Blue

  11. #26
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    no, I don't get errors there, but it's bad programming. thanks for pointing that out.
    updated version:
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 07-29-2008, 04:37 AM
  2. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 05:11 PM
  3. Linking errors with static var
    By Elysia in forum C++ Programming
    Replies: 8
    Last Post: 10-27-2007, 05:24 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Unresolved external on vector inside class constructor
    By Mario F. in forum C++ Programming
    Replies: 13
    Last Post: 06-20-2006, 12:44 PM