C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

classe vector et structure

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
gargamel
Guest





PostPosted: Sun Nov 21, 2004 6:54 pm    Post subject: classe vector et structure Reply with quote



bonjour,
pourquoi une expression comme celle ci n'est pas permise:

#include <iostream>
#include <vector>

using namespace std;

struct complexe
{
int reel,imagine;
};

typedef vector<complexe> tableau;

void charger_tableau(tableau & t)
{
for (int j=0;t.size();j++)
{
t[j]->reel=j;
t[j]->imagine=j;
}

}

int main()
{
return 0;
}




Back to top
Eric Fournier
Guest





PostPosted: Sun Nov 21, 2004 7:21 pm    Post subject: Re: classe vector et structure Reply with quote



"gargamel" <gargamel (AT) gargamel (DOT) fr> a écrit dans le message de
news:41a0e494$0$9062$8fcfb975 (AT) news (DOT) wanadoo.fr...
Quote:
bonjour,
pourquoi une expression comme celle ci n'est pas permise:

#include <iostream
#include
using namespace std;

struct complexe
{
int reel,imagine;
};

typedef vector

void charger_tableau(tableau & t)
{
for (int j=0;t.size();j++)

La bonne condition limite serait j<t.size()

Quote:
{
t[j]->reel=j;
t[j]->imagine=j;
t[j] retourne une référence vers une structure "complexe".

Pour accéder aux éléments d'une structure, utilise l'opérateur point "."
L'opérateur -> sert pour accéder aux membres de pointeurs vers des
structures.

Quote:
}

}

int main()
{
return 0;
}







Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.