ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok, im taking a c++ class in college and i've always had trouble with classes, so far, i kind of understood it good to the point that i got my code going, but when i compile it, something happens, i dunno why, im using that visual c++ since im at home and using my pc not my laptop cus they stole it.
If someone could help me out with this id really appreciate, it could be the headings but i dunno.
here are the class, .h file and the test driver
Invoice.h
Code:
#include <iostream>
#include <string>
using std::string;
class Invoice
{
public:
Invoice(string, string, int, int)
void setPartNumber(string);
string getPartNumber();
void setPartDes(string);
string getPartDesc();
void setQuantity(int);
int getQuantity;
void setPrice(int);
int getPrice();
int getInvoiceAmount();
private:
string PartNumber;
string PartDesc;
int Quantity;
int Price;
};
#include <iostream>
using std::cout;
using std::endl;
#include "invoice.h"
int main()
{
Invoice MyInvoice1("Device 1", "Dell Laptop", 5, 877);
Invoice MyInvoice2("Device 2", "apple ipod", 7, 432);
cout << "The total price of my first Invoice is: $"<< myInvoice1.getInvoiceAmount() << endl;
cout << "The total price of my second Invoice is: $"<< myInvoice2.getInvoiceAmount() << endl;
return 0;
}
Well if someone could help me out, id really appreciate. thanx
I changed it and this is my compiler output, im sorry i hadnt put that before, also you should know its better to put both posts in one. Its easier to read and time saving.
Code:
1>------ Build started: Project: Project, Configuration: Debug Win32 ------
1>Compiling...
1>invoice_test.cpp
1>.\invoice_test.cpp(11) : error C2065: 'myInvoice1' : undeclared identifier
1>.\invoice_test.cpp(11) : error C2228: left of '.getInvoiceAmount' must have class/struct/union
1> type is ''unknown-type''
1>.\invoice_test.cpp(12) : error C2065: 'myInvoice2' : undeclared identifier
1>.\invoice_test.cpp(12) : error C2228: left of '.getInvoiceAmount' must have class/struct/union
1> type is ''unknown-type''
1>Invoice.cpp
1>.\Invoice.cpp(11) : error C3861: 'setPartDesc': identifier not found
1>.\Invoice.cpp(30) : error C2039: 'setPartDesc' : is not a member of 'Invoice'
1> c:\documents and settings\hp_owner\my documents\visual studio 2005\projects\project\project\invoice.h(5) : see declaration of 'Invoice'
1>.\Invoice.cpp(31) : error C2365: 'setPartDesc' : redefinition; previous definition was 'formerly unknown identifier'
1>.\Invoice.cpp(32) : error C2065: 'PartDesc' : undeclared identifier
1>.\Invoice.cpp(46) : error C2063: 'Invoice::getQuantity' : not a function
1>.\Invoice.cpp(57) : error C2065: 'p' : undeclared identifier
1>.\Invoice.cpp(62) : error C2065: 'Quantitie' : undeclared identifier
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\HP_Owner\My Documents\Visual Studio 2005\Projects\Project\Project\Debug\BuildLog.htm"
1>Project - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
also if anyone is as a guest and could help me but is not registered, please add me to k1ll3r_x@hotmail.com, id really appreciate the help.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.