Solved

uses undefined class???

Posted on 2004-08-21
3
648 Views
Last Modified: 2008-03-10
I've got:

/////////CPair.cpp:
class CPair{
   //stuff here...
}

//CPair::methods...


////////Main.cpp:
void someMethod(){
    CPair pair;
}

but it's complaining that the CPair class is undefined?!?!?! How can I get around this??? Maybe some header file? :S
0
Comment
Question by:Unimatrix_001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 500 total points
ID: 11859625
generally you will have  a

1) Cpair.h file with the


class CPair{
   //stuff here...
}
 
and then a Cpair.cpp

2) Cpair.cpp which will have

#include "Cpair.h"

CPair::methods...

3.) Main.cpp

which will have

#include "CPair.h"

void someMethod(){
    CPair pair;
}


================
the reason you are getting is because the file main.cpp cannot see the declaration/definition of CPair




0
 
LVL 11

Expert Comment

by:avizit
ID: 11859659
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 11859761
Thank you :) ...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question