[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Undeclared Identifier - Part 2

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
dpms
Asked:
dpms
1 Solution
 
vsinhaCommented:
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
 
larockdCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now