[code]
int main ( int argc, char *argv[] )
{
// ...
return 0;
}
[/code]
Tako uokviren (formatizovan) kod će se videti ovako:
int main ( int argc, char *argv[] )
{
// ...
return 0;
}
zasto nece da radi ako definisem Position *pok,a radi za Position pok?
ovo radi:
#include <iostream.h>
class Position {
int x, y;
public:
Position();
Position(Position& );
void set(int new_x, int new_y);
void get(int* current_x, int* current_y);
};
Position::Position()
{
x = 0;
y = 0;
}
void
Position::set(int new_x, int new_y)
{
x = new_x;
y = new_y;
}
void
Position::get(int* current_x, int* current_y)
{
*current_x = x;
*current_y = y;
}
Position
position;
void
position_input(Position* p)
{
int a,b;
cin>>a;
cin>>b;
p->set(a,b);
}
int
main()
{
int x, y;
position.get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
position.set(5,7);
position.get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
Position pok;
position_input(&pok);
pok.get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
}
a ovo ne:
#include <iostream.h>
class Position {
int x, y;
public:
Position();
Position(Position& );
void set(int new_x, int new_y);
void get(int* current_x, int* current_y);
};
Position::Position()
{
x = 0;
y = 0;
}
void
Position::set(int new_x, int new_y)
{
x = new_x;
y = new_y;
}
void
Position::get(int* current_x, int* current_y)
{
*current_x = x;
*current_y = y;
}
Position
position;
void
position_input(Position* p)
{
int a,b;
cin>>a;
cin>>b;
p->set(a,b);
}
int
main()
{
int x, y;
position.get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
position.set(5,7);
position.get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
Position* pok;
position_input(pok);
pok->get(&x, &y);
cout << "X=" << x << ", Y=" << y << "\n";
}
[Ovu poruku je menjao X Files dana 28.02.2007. u 07:25 GMT+1]