Click here to Skip to main content
15,913,587 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: createprocess Pin
PJ Arends4-Mar-06 11:52
professionalPJ Arends4-Mar-06 11:52 
QuestionDeploying a VC++ application on a target machine Pin
Themis4-Mar-06 6:53
Themis4-Mar-06 6:53 
AnswerRe: Deploying a VC++ application on a target machine Pin
Richard_484-Mar-06 12:50
Richard_484-Mar-06 12:50 
GeneralRe: Deploying a VC++ application on a target machine Pin
Themis4-Mar-06 21:27
Themis4-Mar-06 21:27 
GeneralRe: Deploying a VC++ application on a target machine Pin
Gary R. Wheeler5-Mar-06 3:07
Gary R. Wheeler5-Mar-06 3:07 
AnswerRe: Deploying a VC++ application on a target machine Pin
Michael Dunn5-Mar-06 6:34
sitebuilderMichael Dunn5-Mar-06 6:34 
QuestionText Justification Pin
Richard_484-Mar-06 5:50
Richard_484-Mar-06 5:50 
QuestionRe Post of earlier message - ANSI String in Classes Pin
Tom Moore4-Mar-06 4:45
Tom Moore4-Mar-06 4:45 
Hi,

I'm wondering if I can use the ANSI String Class in normal classes.

I tried yesterday and got an error.


Product.h
#include "string.h"
#include "iostream.h"

using namespace std;
class Product
{
public:
Product(Product&);
Product(string name, int amount , float price);
float GetPrice();
void SetPrice(float price);
void SetAmount(int Amount);
int GetAmount();
void SetName(string name);
string GetName();
Product();
virtual ~Product();
private:
float itsPrice;
int itsAmount;
string itsName;
};


Product.cpp
Product::Product()
{

}

Product::~Product()
{

}

string Product::GetName()
{
return itsName;
}

void Product::SetName(string name)
{
itsName = name;
}

int Product::GetAmount()
{
return itsAmount;
}

void Product::SetAmount(int Amount)
{
itsAmount = Amount;
}

void Product::SetPrice(float price)
{
itsPrice = price;
}

float Product::GetPrice()
{
return itsPrice;
}

Product::Product(string name, int amount, float price)
{
itsName = name;
itsAmount = amount;
itsPrice = price;
}

Product::Product(Product &rhs)
{
itsName = rhs.GetName();
itsPrice = rhs.GetPrice();
itsAmount = rhs.GetAmount();
}


main.cpp

#include "iostream.h"
#include "Product.h"
using namespace std;


int main()
{
Product p1("Apple",0.25,50);

cout << p1.GetName();
int s;
std::cin >> s;

return 0;
}



The error is : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string,class std::allocator >' (or there is no acceptable conversion)

Please help.

Thanks in advance

Tom
AnswerRe: Re Post of earlier message - ANSI String in Classes Pin
Nemanja Trifunovic4-Mar-06 4:47
Nemanja Trifunovic4-Mar-06 4:47 
GeneralRe: Re Post of earlier message - ANSI String in Classes Pin
Tom Moore4-Mar-06 5:01
Tom Moore4-Mar-06 5:01 
GeneralRe: Re Post of earlier message - ANSI String in Classes Pin
Nemanja Trifunovic4-Mar-06 5:20
Nemanja Trifunovic4-Mar-06 5:20 
QuestionStack Overflow, possible cause? Pin
Waldermort4-Mar-06 4:16
Waldermort4-Mar-06 4:16 
AnswerRe: Stack Overflow, possible cause? Pin
Christian Graus4-Mar-06 5:13
protectorChristian Graus4-Mar-06 5:13 
GeneralRe: Stack Overflow, possible cause? Pin
Waldermort4-Mar-06 5:33
Waldermort4-Mar-06 5:33 
GeneralI FOUND IT!!! Pin
Waldermort4-Mar-06 7:57
Waldermort4-Mar-06 7:57 
GeneralRe: I FOUND IT!!! Pin
John R. Shaw4-Mar-06 15:51
John R. Shaw4-Mar-06 15:51 
GeneralRe: I FOUND IT!!! Pin
Waldermort4-Mar-06 21:08
Waldermort4-Mar-06 21:08 
GeneralRe: I FOUND IT!!! Pin
John R. Shaw5-Mar-06 14:21
John R. Shaw5-Mar-06 14:21 
Questionmemcat() Pin
chaitanya224-Mar-06 3:44
chaitanya224-Mar-06 3:44 
AnswerRe: memcat() Pin
Gary R. Wheeler4-Mar-06 4:28
Gary R. Wheeler4-Mar-06 4:28 
QuestionAppending arrays Pin
chaitanya224-Mar-06 3:43
chaitanya224-Mar-06 3:43 
AnswerRe: Appending arrays Pin
John R. Shaw4-Mar-06 15:56
John R. Shaw4-Mar-06 15:56 
Questionword counter using threadings Pin
nanjesh4-Mar-06 3:37
nanjesh4-Mar-06 3:37 
AnswerRe: word counter using threadings Pin
Saurabh.Garg4-Mar-06 13:40
Saurabh.Garg4-Mar-06 13:40 
Questionword counter using threadings Pin
nanjesh4-Mar-06 3:36
nanjesh4-Mar-06 3:36 

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.