 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
gargamel Guest
|
Posted: Sun Nov 21, 2004 6:54 pm Post subject: classe vector et structure |
|
|
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
|
Posted: Sun Nov 21, 2004 7:21 pm Post subject: Re: classe vector et structure |
|
|
"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 |
|
 |
|
|
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
|
|