[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Undeclared Identifier - Part 2

Posted on 1998-03-17
2
Medium Priority
?
293 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
[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 Comments
 
LVL 1

Accepted Solution

by:
vsinha earned 100 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

656 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