Solved

Undeclared Identifier - Part 2

Posted on 1998-03-17
2
273 Views
Last Modified: 2010-04-10
Okay the last one was a stupid spelling oversight. But I can't see why I get a "undeclared identifier" error everytime  I use the instance of the class as an arguement. The code snippet follows:

class CIntegerSet
{
public:
CIntegerSet (int,int,int,int,int);
CIntegerSet ();
void UnionOfIntegerSets                         (CIntegerSet &, CIntegerSet &);
CIntegerSet IntersectionOfIntegerSet (CIntegerSet &, CIntegerSet &);
void InsertElement (CIntegerSet &, int);
void DeleteElement (CIntegerSet &, int);
void SetPrint         (CIntegerSet &);
bool IsEqual         (CIntegerSet &, CIntegerSet &);
private:
      int IntArray[100];
};

int main ()
{

CIntegerSet IntSet1(4, 9, 21, 13, 44);
CIntegerSet IntSet2(3, 7, 33, 62, 75);
CIntegerSet IntSet3();

UnionOfIntegerSets(IntSet1, IntSet2);  // error HERE

SetPrint(IntSet3); //error HERE

InsertElement(IntSet1, 15);  //error HERE
InsertElement(IntSet2, 15);   // funny, no error here
0
Comment
Question by:dpms
2 Comments
 
LVL 1

Accepted Solution

by:
vsinha earned 50 total points
ID: 1183572
Whenever you call a method, you should first write the name of the associated class, followed by a '.', followed by the method name.

From what you have done I think you want to do the following:

class CIntegerSet
   {
...
   void InsertElement (int);
   void DeleteElement (int);
   void SetPrint    ();
...
   };


   int main ()
   {

   CIntegerSet IntSet1(4, 9, 21, 13, 44);
   CIntegerSet IntSet2(3, 7, 33, 62, 75);
   CIntegerSet IntSet3();

   ...

   IntSet3.SetPrint();
   IntSet1.InsertElement(15);
   IntSet2.InsertElement(15);

}


I would suggest you to look at an example, before going further. I can find a good example on a matrix class if you are interested.




0
 

Expert Comment

by:larockd
ID: 1183573
The compiler is also going to bark about your constructor...  
Once you fix your other compile errors your constructor is going to cause an error.
CIntegerSet (int,int,int,int,int); This will produce an unresolved identifer LNK 1120 error..

Above is how you declare it....  Needs to be declared like this
CIntegerSet (int,int,int,int,int) {};

Plus you might actually want to do something in the constructor also...

Darrell


0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now