Click here to Skip to main content
15,879,095 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Compiler is ignoring code - VC 6.0 SOLVED Pin
jschell8-Jan-11 9:05
jschell8-Jan-11 9:05 
GeneralRe: Compiler is ignoring code - VC 6.0 SOLVED Pin
Vaclav_8-Jan-11 9:17
Vaclav_8-Jan-11 9:17 
QuestionExpanding items in CTreeCtrl Pin
Sakhalean8-Jan-11 3:16
Sakhalean8-Jan-11 3:16 
AnswerRe: Expanding items in CTreeCtrl Pin
User 74293388-Jan-11 3:42
professionalUser 74293388-Jan-11 3:42 
AnswerRe: Expanding items in CTreeCtrl Pin
jk chan8-Jan-11 5:24
jk chan8-Jan-11 5:24 
AnswerRe: Expanding items in CTreeCtrl Pin
janaswamy uday8-Jan-11 6:55
janaswamy uday8-Jan-11 6:55 
JokeRe: Expanding items in CTreeCtrl Pin
User 74293388-Jan-11 7:19
professionalUser 74293388-Jan-11 7:19 
QuestionOperator >> istream [modified] Pin
Amine MAMA8-Jan-11 1:31
Amine MAMA8-Jan-11 1:31 
Hello ,
i have the problem in run of this code can you view this code and give me the solution
code of produit.h:
#pragma once
#include <iostream>
#include <string.h>
using namespace std;
class produit
{
private:
	int code;
	char* edsignation;
	static int totalprod;
public:
produit(const produit&);
produit&operator=(const produit&);
friend ostream& operator<<(ostream&,const produit&);
friend istream& operator>>(istream&, produit&);
	produit(int=0,char*p="");
	~produit(void);
};


code of produit.cpp :
#include "produit.h"
int produit::totalprod=0;

produit::produit(int x,char* d)
{
	this->code=x;
	this->edsignation=new char[strlen(d)+1];
	strcpy(this->edsignation,d);
	produit::totalprod++;
}
produit::produit(const produit&p){
this->code=p.code;
this->edsignation=new char[strlen(p.edsignation)+1];
strcpy(this->edsignation,p.edsignation);
}
produit& produit::operator=(const produit&p){
	if(this!=&p){
this->code=p.code;
this->edsignation=new char[strlen(p.edsignation)+1];
strcpy(this->edsignation,p.edsignation);
	}
	return (*this);
}
produit::~produit(void)
{
	//if(edsignation) {
		delete [] edsignation;
	//	edsignation=0;}
}
 ostream& operator<<(ostream& o,const produit&p){
	 o<<p.code<<" "<<p.edsignation<<" "<<produit::totalprod<<endl;
return o;
}
  istream& operator>>(istream& i,produit&p){
	  if(p.edsignation) delete [] p.edsignation;
		  i>>p.code;
 i>>p.edsignation;
return i;
}

Thanks.
AnswerRe: Operator >> istream Pin
Luc Pattyn8-Jan-11 1:36
sitebuilderLuc Pattyn8-Jan-11 1:36 
AnswerRe: Operator >> istream Pin
Amine MAMA8-Jan-11 1:44
Amine MAMA8-Jan-11 1:44 
AnswerRe: Operator >> istream Pin
Luc Pattyn8-Jan-11 2:20
sitebuilderLuc Pattyn8-Jan-11 2:20 
AnswerRe: Operator >> istream Pin
User 74293388-Jan-11 2:57
professionalUser 74293388-Jan-11 2:57 
GeneralRe: Operator >> istream Pin
Amine MAMA8-Jan-11 3:14
Amine MAMA8-Jan-11 3:14 
AnswerRe: Operator >> istream Pin
User 74293388-Jan-11 3:33
professionalUser 74293388-Jan-11 3:33 
GeneralRe: Operator >> istream Pin
Amine MAMA8-Jan-11 7:36
Amine MAMA8-Jan-11 7:36 
AnswerRe: Operator >> istream Pin
Aescleal8-Jan-11 5:34
Aescleal8-Jan-11 5:34 
QuestionGetting LogicalDriveInformation of different hard disks..... Pin
learningvisualc8-Jan-11 1:02
learningvisualc8-Jan-11 1:02 
AnswerRe: Getting LogicalDriveInformation of different hard disks..... Pin
User 74293388-Jan-11 1:26
professionalUser 74293388-Jan-11 1:26 
AnswerRe: Getting LogicalDriveInformation of different hard disks..... Pin
Luc Pattyn8-Jan-11 1:33
sitebuilderLuc Pattyn8-Jan-11 1:33 
QuestionRe: Getting LogicalDriveInformation of different hard disks..... Pin
David Crow10-Jan-11 5:48
David Crow10-Jan-11 5:48 
QuestionRead Serial Port data [modified] Pin
shiv@nand8-Jan-11 0:15
shiv@nand8-Jan-11 0:15 
AnswerRe: Read Serial Port data Pin
User 74293388-Jan-11 1:48
professionalUser 74293388-Jan-11 1:48 
AnswerRe: Read Serial Port data Pin
Richard MacCutchan8-Jan-11 2:36
mveRichard MacCutchan8-Jan-11 2:36 
QuestionPopulate An Array With Numbers. Pin
Mike Certini7-Jan-11 10:39
Mike Certini7-Jan-11 10:39 
AnswerRe: Populate An Array With Numbers. Pin
Nuri Ismail7-Jan-11 10:48
Nuri Ismail7-Jan-11 10:48 

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.