Type name expected error

This is a discussion on Type name expected error within the C++ Programming forums, part of the General Programming Boards category; I'm working on a final project for my advanced C++ class and my teacher is kinda baffled as well on ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    38

    Type name expected error

    I'm working on a final project for my advanced C++ class and my teacher is kinda baffled as well on this error. I'm hoping someone can see something wrong in this program. I'm enclosing my 4 header files and the main driver program. The errors are:
    Type name expected
    Can't convert (int*) to (account*)
    Missing statement ;

    Each case statement 1-3 in my main program are receiving these errors. When I view the error it falls in the dynamic memory allocation line 'p=new' of the case. If anybody can help me out here I would greatly appreciate it.
    One thing: it might have something to do with the ifndef and define statements or the #include statements within the header files. The book doesn't go into any detail about this, and our teacher is teaching this class for the first time. Thanks for any help.
    Attached Files Attached Files
    SilasP

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    for the first one, you are probably trying to type cast an integer pointer to a user defined conglomerate type [account] pointer... this cannot be done... check to see if the source and destination variables match...

    for the second one, either you did not terminate a statement with a semicolon, or you have one after too many parenthesis...

    what are the line numbers on the errors?
    hasafraggin shizigishin oppashigger...

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    38

    Exact error locations

    The errors are being referenced back to my main program. They come up on the lines that have the statement p= new within the case statements. The thing I can't figure out is where it is coming up with an 'int *'. I haven't declared any pointers other than account type. The statement missing ; error is completely off the wall; I can look at it and say, there isn't one missing.
    All help is greatly appreciated
    SilasP

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    I'm sorry to say that, but I worked on it half an hour now, and there are way too many errors for me to fix them for you and explain.

    1) case '01':
    You are switching an int. Test against an int: "case 1:"

    2) default constructors

    derivedclass::derivedclass() : baseclass()
    {
    // do stuff
    }

    check this for ALL your classes

    3) possible data loss by converting from double to int and back to double. check it, your compiler should issue a warning

    4) default parameters can only be given ONCE. set them in the prototype, leave them out in the implementation.

    5) The #defines in the headers are wrong. For starters, delete them all. Once you know what they do, put them back in one by one.

    6) the stringclass you use is non-standard and incomprehensible to me. Ask your teacher to use a standard string class like 'string' from the stl. Not being able to compile your program without it makes it hard to search for errors.



    The errors you experienced were caused by the defines. The compiler didn't see your classes. Once he sees them, brace yourself for a truckload of errors to come up. Handle them one by one. Go to the line of the error and check for the points above.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    38

    ifndef and define statements

    Thanks for checking out my program. I was wondering if I could ask one favor from you. Our book doesn't describe the ifndef and define statements into any depth whatsoever. With the classes I have in my program, could you describe how those statements should be used. I would ask my teacher, but she doesn't know either. Thanks a lot.

    Silas P
    SilasP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 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. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21