C++ question

Discussion in 'OT Technology' started by nayt1, Sep 6, 2005.

  1. nayt1

    nayt1 New Member

    Joined:
    Aug 9, 2004
    Messages:
    15,590
    Likes Received:
    0
    Location:
    CTU Orlando
    i have a class made up of a cpp file and a header file.

    i added the cpp file, wavefront.cpp to my project (visual studio 6). in my program file p2.cpp, i wrote:

    i get the error

    first time using c++, why does it say the class is undefined if i added its file to the project and compiled? what do i need to do to make it recognize that class?
     
  2. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    Did you remember to include the header file where you class is declared in p2.cpp:

    #include "wavefront.h"
     
  3. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    :werd:
     
  4. nayt1

    nayt1 New Member

    Joined:
    Aug 9, 2004
    Messages:
    15,590
    Likes Received:
    0
    Location:
    CTU Orlando
    when i do that, i get all sorts of wierd errors. when i get home i'll try to compile it again and post them.
     
  5. MovieMan84

    MovieMan84 Here we go

    Joined:
    Sep 10, 2002
    Messages:
    4,374
    Likes Received:
    0
    Location:
    Redmond
    In for helping you fix all of your weird errors later.

    I'm sure it's something minor that you've overlooked.
     
  6. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    Are you including the header from multiple source files? If so, you'll need to put preprocessor boilerplate statements to prevent the compiler from including the header file multiple times. Example:

    Code:
    #ifndef foo_h__
    #define foo_h__
    
    /* contents of foo.h header file */
    
    #endif
    
     

Share This Page