Click here to Skip to main content
15,912,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Serial port and USB Pin
Bob Stanneveld10-Sep-05 2:07
Bob Stanneveld10-Sep-05 2:07 
QuestionPrint in PrintPreview problem Pin
mikobi9-Sep-05 20:26
mikobi9-Sep-05 20:26 
AnswerRe: Print in PrintPreview problem Pin
David Crow10-Sep-05 17:15
David Crow10-Sep-05 17:15 
GeneralRe: Print in PrintPreview problem Pin
mikobi11-Sep-05 19:21
mikobi11-Sep-05 19:21 
GeneralRe: Print in PrintPreview problem Pin
David Crow12-Sep-05 2:38
David Crow12-Sep-05 2:38 
QuestionCListCtrl: Change position first/last item position in Icon mode Pin
phieu9-Sep-05 18:03
phieu9-Sep-05 18:03 
AnswerRe: CListCtrl: Change position first/last item position in Icon mode Pin
Anonymous9-Sep-05 23:31
Anonymous9-Sep-05 23:31 
QuestionDeclaring Vectors Pin
Anonymous9-Sep-05 15:20
Anonymous9-Sep-05 15:20 
yes i wana make a vector for a object

eg. **************PROPERTY.h FILE***********

#ifndef Property_h
#define Property_h

#include <string>
#include <vector>
using std::string;
using std::vector;

class Property
{
public:
Property();
Property (string a_address, string a_suburb, int a_price);
void print() const;
void getProperty();
//int readFile(vector<property>, myCard);
void listAll(vector<property> propvect); <<<<<< thing to look at error possibly here
int menu();

private:
string address_string;
string suburb_string;
int price_int;

};

#endif



**********PROPERTY.CPP FILE************


#include <iostream>
#include <string>
#include "Property.h"
#include <vector>
#include <fstream>

using namespace std;
Property::Property()
{


}

Property::Property(string a_address, string a_suburb, int a_price)
{
address_string = a_address;
suburb_string = a_suburb;
price_int = a_price;
}

void Property::print() const
{
cout << address_string << " " << suburb_string << " " << price_int << endl;
system("Pause");
}

void Property::getProperty()
{
cout << "Enter address: ";
getline(cin, address_string);
cout << "Enter suburb: ";
getline(cin, suburb_string);
cout << "Enter price: ";
cin >> price_int;
}

int Property::menu()
{
int option = 0;

cout << endl;
cout << "Menu:" << endl;
cout << "1 - List all properties" << endl;
cout << "2 - Property search" << endl;
cout << "3 - Add a property" << endl;
cout << "4 - Save property list" << endl;
cout << "5 - Exit" << endl << endl;

cout << "Please enter option: ";
cin >> option;

string remainder;
getline(cin, remainder);

cout << endl;

return option;
}

void Property::listAll(vector<property> propvect) <<<<<<< FUCTION THAT HAS THE ERROR
{
for (int i = 0; i < propvect.size(); i++)
{
cout << "$" << propvect[i].address_string << " ";
cout << propvect[i].suburb_string << " ";
cout << propvect[i].price_int << endl;
}
}


***********PROPERTY_TEST.CPP ********** TEST HARNESS FOR PROPERTY PROGRAM

#include <iostream>
#include <string>
#include <vector>

#include "Property.h"

using namespace std;

int main()
{
int option = 0;
bool done = false;

vector<property> propvect;
Property Properties;

// readFile(vector<property>, myCard);

do
{
option = Properties.menu();

switch (option)
{
case 1: Properties.listAll(vector<property> propvect);
/*Properties.print();*/break;

case 2: //search(properties, items); break;

case 3: Properties.getProperty();
propvect.push_back(Properties); break;

case 4: //saveProperties(properties, items); break;
case 5: done = true; break;

default: cout << "Illegal menu option" << endl;
}

} while(!done);

return 0;
}




____________________________________________________________________________________________



now when i run it without the ListALL fuction it works but when i run it with the ListALL fuction i get syntax errors can anyone see what im doing wrong.
AnswerRe: Declaring Vectors Pin
Chris Losinger9-Sep-05 16:35
professionalChris Losinger9-Sep-05 16:35 
Answer[Message Deleted] Pin
SummoningDan9-Sep-05 16:45
SummoningDan9-Sep-05 16:45 
QuestionBitmap button dose not displayed Pin
johnnyXP9-Sep-05 11:54
johnnyXP9-Sep-05 11:54 
AnswerRe: Bitmap button dose not displayed Pin
Michael Dunn9-Sep-05 19:31
sitebuilderMichael Dunn9-Sep-05 19:31 
QuestionBitmap button messages Pin
fleetmanager9-Sep-05 10:50
fleetmanager9-Sep-05 10:50 
AnswerRe: Bitmap button messages Pin
khan++9-Sep-05 21:07
khan++9-Sep-05 21:07 
GeneralRe: Bitmap button messages Pin
fleetmanager12-Sep-05 16:24
fleetmanager12-Sep-05 16:24 
Questiontemplates and libs/dlls Pin
zildjohn019-Sep-05 10:36
zildjohn019-Sep-05 10:36 
AnswerRe: templates and libs/dlls Pin
Chris Losinger9-Sep-05 10:47
professionalChris Losinger9-Sep-05 10:47 
GeneralRe: templates and libs/dlls Pin
zildjohn0110-Sep-05 13:35
zildjohn0110-Sep-05 13:35 
GeneralRe: templates and libs/dlls Pin
Nemanja Trifunovic10-Sep-05 13:44
Nemanja Trifunovic10-Sep-05 13:44 
GeneralRe: templates and libs/dlls Pin
zildjohn0110-Sep-05 15:01
zildjohn0110-Sep-05 15:01 
GeneralRe: templates and libs/dlls Pin
Chris Losinger10-Sep-05 14:30
professionalChris Losinger10-Sep-05 14:30 
Questionmemory leak question Pin
valerie999-Sep-05 9:46
valerie999-Sep-05 9:46 
AnswerRe: memory leak question Pin
David Crow9-Sep-05 10:09
David Crow9-Sep-05 10:09 
GeneralRe: memory leak question Pin
valerie999-Sep-05 10:27
valerie999-Sep-05 10:27 
AnswerRe: memory leak question Pin
QuiJohn9-Sep-05 10:15
QuiJohn9-Sep-05 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.