MrJabbaNoHere's Profile
Reputation: 1
Apprentice
- Group:
- Members
- Active Posts:
- 29 (0.03 per day)
- Joined:
- 08-March 11
- Profile Views:
- 261
- Last Active:
May 01 2013 02:19 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Trouble Compiling with fatal "multiply-defined" errors in UNIX
Posted 1 Dec 2011
I see, but how am I supposed to have both my default constructor and my explicit value constructor if the compiler sees it as multiply defined? -
In Topic: "Class has not been declared" issue
Posted 1 Dec 2011
I can compile BST.cpp by itself using g++ BST.cpp -c
But I cannot compile all 3 files together with g++ BST.cpp BST.h TreeNode.h
I suppose I need to write a main() function in order to compile all of the files to write to a.out -
In Topic: "Class has not been declared" issue
Posted 1 Dec 2011
jimblumberg, on 01 December 2011 - 02:32 PM, said:In the following snippet:
void BST::insert(const int & item) { BST::TreeNodePointer locptr = myRoot, // search pointer parent = 0; // pointer to parent of current node if (!found) { // construct node containing item locptr = new BST::TreeNode(item);
You do not need the BST:: . This function is part of BST so it has access to all members of this class. By adding this BST:: you are just confusing yourself and the compiler.
Jim
Yes, I learned that I do not need this. My code currently looks like
void BST::insert(const int & item) { TreeNodePointer locptr = myRoot, // search pointer parent = 0; // pointer to parent of current node bool found = false; // indicates if item already in BST while (!found && locptr != 0) { parent = locptr; if (item < locptr->data) // descend left locptr = locptr->Lchild; else if (locptr->data < item) // descend right locptr = locptr->Rchild; else // item found found = true; } if (!found) { // construct node containing item locptr = new TreeNode(item); if (parent == 0) // empty tree myRoot = locptr; else if (item < parent->data ) // insert to left of parent parent->Lchild = locptr; else // insert to right of parent parent->Rchild = locptr; } else cout << "Item already in the tree\n"; }
When I compile I get
"Undefined first referenced
symbol in file
main /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status" -
In Topic: "Class has not been declared" issue
Posted 1 Dec 2011
Could someone please help me figure out why I am getting the error?:
"Undefined first referenced
symbol in file
main /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status" -
In Topic: "Class has not been declared" issue
Posted 28 Nov 2011
vividexstance, on 28 November 2011 - 04:01 PM, said:You made a typedef in the BST class called "TreeNodePointer". However, in the BST.cpp file, you refer to just a "TreeNode" and you qualify it with "BST::". Since "TreeNode" is not declared inside "BST", you are getting this error. You either need to drop the explicit qualification or just change the "TreeNode" to "TreeNodePointer".
I cannot change "TreeNode" to "TreeNodePointer" because TreeNodePointer is a pointer to a TreeNode, and I cannot construct a pointer. If I drop the "BST::" then I get the error
"Undefined first referenced
symbol in file
main /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status"
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
MrJabbaNoHere has no profile comments yet. Why not say hello?