hello all
working on a class project in C++ using eclipse and g++ stuck a zip of the project as an attachment but here is the basics

#include <iostream>
#include "Complex.h"
#include "FileHandling.h"

using namespace std;

int main(int argc, char **argv) {
	FileHandling file();// opens the file and gets the variables from last use
	Complex complex();//creates an object of complex
	complex().setRepairPtr(file().getRapairPtr());//pulls the repair pointer in file and sends it to complex
	complex().setNumberOfUnits(file().getNumUnits());//pulls the number of units in file and sends it to complex
	complex().setNumberOfRepairs(file().getNumRepair());//pulls the number of repairs in file and sends it to complex
	complex().setUnitPtr(file().getUnitsPtr());//pulls the unit pointer in file and sends it to complex
	complex().buildVectors();//used to build Vectors in complex and all units
	complex().start();//starts the interface part of the program
	//now that the interface has ended the program must save and then exit
	file().setRepairPtr(complex().getRepairPtr());//returns the repair pointer to file for output in case of change to original
	file().setUnitsPtr(complex().getUnitPtr());//returns the pointer for units to file for output in case of change to original
	file().setNumRepair(complex().getNumberOfRepairs());//sets the number of repairs for use as an array in conjunction with pointers
	file().setNumUnits(complex().getNumberOfUnits());//sets the number of units for use as an array in conjunction with pointers
	return 0;
}

i get "undefined reference to 'complex()'" errors on the complex() lines
and "undefined reference to 'file()'" errors on the file() lines

then when i try to use array lists in side the objects compiler says "undefined reference to 'Complex::complexList()'" complexList being a vector in my complex object.
slimier issues inside other sub objects

any help would be much appreciated:?:

Recommended Answers

All 9 Replies

You don't need the () when using a default constructor nor do you need them on the object when invoking a method (you do need them on the method call itself)

complex().setRepairPtr(file().getRapairPtr());

should be 
complex.setRepairPtr(file.getRapairPtr());

and your object declaration should be 
Complex complex;

The second part of your question I'm not sure of, but if you are dynamically allocating those objects then you'd need to take care of that in the constructor of the object being called.

You don't need the () when using a default constructor nor do you need them on the object when invoking a method (you do need them on the method call itself)

complex().setRepairPtr(file().getRapairPtr());

should be 
complex.setRepairPtr(file.getRapairPtr());

and your object declaration should be 
Complex complex;

The second part of your question I'm not sure of, but if you are dynamically allocating those objects then you'd need to take care of that in the constructor of the object being called.

sweet that fixed it may be back with the new issue thank you jonsca

this may just be a new error but after removing the () im getting errors of request for member 'function name' in 'object name' which is of non-class type 'object name () ()'

I haven't figured out what's up with the error you posted but looking closer at your code, you should probably rename complex.h to something else because that's the name of the old (non-standard) complex number header. It doesn't give an error but there are warnings about it.

There are a bunch of changes

take off the () these are not methods, these are members
        vector<Tenants> complexList;//holds a vector of tenants
	vector<Repairs> repairsList;//holds a vector of repair

//take off the () on complexList, again not a method
for (int i = 0; i < numberOfUnits; ++i) {
			cout << i+1 << " " <<complexList[i].getTenantName();

//there's a ton more, like in here (I didn't change them)
cout << "Tenant Name: " << complexList()[unitNum].getTenantName() << endl;
	cout << "Unit Number: " << complexList()[unitNum].getUnitNumber() << endl;
	cout << "Balance Due: $" << complexList()[unitNum].getBalanceDue() << endl;
	cout << "Size: " << complexList()[unitNum].getUnitSize() << " BedRooms\n";
	cout << "Number Of Repairs: " << complexList()[unitNum].getAptNumberOfrepairs() << endl;

Do the same for repairslist
There are a couple of spelling errors in Tenants.cpp (repiarlist) which are also causing errors -- on top of that when they are corrected to repairsList, it's not in scope in Tenants.cpp

ok made the revisions and still getting the "undefined reference to 'complex()'" errors on the complex() lines
and "undefined reference to 'file()'" errors on the file() lines errors attached the new code
sorry to have so many problems I've been hacking away at this code for the better part of a week and am sure im missing stuff i should know also the vectors lecture is next semester so im pulling most of this from my java array list knowledge and crash coursing the internet

ok made the revisions and still getting the "undefined reference to 'complex()'" errors on the complex() lines
and "undefined reference to 'file()'" errors on the file() lines errors attached the new code
sorry to have so many problems I've been hacking away at this code for the better part of a week and am sure im missing stuff i should know also the vectors lecture is next semester so im pulling most of this from my java array list knowledge and crash coursing the internet

There shouldn't be any complex() lines or file() lines (outside of their constructor definitions in their own class files) it should be object.method() across the board.

EDIT: These are still around (in complexinterface.h):

vector<Tenants> complexList();//holds a vector of tenants
	vector<Repairs> repairsList();//holds a vector of repairs

get rid of the ()

Another random thing: tenants.h has vector.h included it should just be <vector>

Demo and file handling still have complex.h

And this:
ComplexInterface theComplex();
is still not right.
nor FileHandling file();

thanks again jonsca
posting final code as archive for anyone who needs it as GPL

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.