Click here to Skip to main content
16,021,823 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
Questionsimulate a real race condition Pin
zhshqzyc4-Mar-06 2:25
zhshqzyc4-Mar-06 2:25 
QuestionCan I use the ANSI String Class in a normal class Pin
Tom Moore4-Mar-06 1:36
Tom Moore4-Mar-06 1:36 
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
#include
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


-- modified at 8:04 Saturday 4th March, 2006
AnswerRe: Can I use the ANSI String Class in a normal class Pin
Gary R. Wheeler4-Mar-06 1:51
Gary R. Wheeler4-Mar-06 1:51 
Questioncan I do win32 app without vc? Pin
derek74-Mar-06 1:19
derek74-Mar-06 1:19 
AnswerRe: can I do win32 app without vc? Pin
Nemanja Trifunovic4-Mar-06 2:37
Nemanja Trifunovic4-Mar-06 2:37 
QuestionCSocket: Making the application wait till a Blocking call gets over Pin
Spykraft3-Mar-06 23:20
Spykraft3-Mar-06 23:20 
QuestionHow to use WSAAsyncSelect in windows service Pin
milkyhonglee3-Mar-06 22:15
milkyhonglee3-Mar-06 22:15 
AnswerRe: How to use WSAAsyncSelect in windows service Pin
Peter Weyzen4-Mar-06 8:52
Peter Weyzen4-Mar-06 8:52 
GeneralHow about WSAEventSelect? Pin
milkyhonglee4-Mar-06 14:30
milkyhonglee4-Mar-06 14:30 
Question$(ConfigurationName) Pin
derek73-Mar-06 21:40
derek73-Mar-06 21:40 
AnswerRe: $(ConfigurationName) Pin
Gary R. Wheeler4-Mar-06 2:19
Gary R. Wheeler4-Mar-06 2:19 
GeneralRe: $(ConfigurationName) Pin
derek74-Mar-06 3:19
derek74-Mar-06 3:19 
GeneralRe: $(ConfigurationName) Pin
Gary R. Wheeler4-Mar-06 4:06
Gary R. Wheeler4-Mar-06 4:06 
GeneralRe: $(ConfigurationName) Pin
derek75-Mar-06 17:42
derek75-Mar-06 17:42 
Questiondebug function in dll Pin
derek73-Mar-06 21:11
derek73-Mar-06 21:11 
AnswerRe: debug function in dll Pin
Malli_S3-Mar-06 21:37
Malli_S3-Mar-06 21:37 
GeneralRe: debug function in dll Pin
derek73-Mar-06 21:58
derek73-Mar-06 21:58 
Questionc++ Pin
yaaqub3-Mar-06 21:09
yaaqub3-Mar-06 21:09 
AnswerRe: c++ Pin
Gary R. Wheeler4-Mar-06 4:33
Gary R. Wheeler4-Mar-06 4:33 

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.