#include <iostream>
#include <cstdlib>
struct data{
std::string name;
std::string city;
data *prevPtr;
};
int main(int argc, char *argv[]){
system("color 2f");
data zero;
zero.name = "Lady Gaga";
zero.city = "NYC";
zero.prevPtr = NULL;
data satu;
satu.name = "Luna Maya";
satu.city = "Denpasar";
satu.prevPtr = &zero;
data dua;
dua.name = "Bill Clinton";
dua.city = "Virginia";
dua.prevPtr = &satu;
data tiga;
tiga.name = "Barack Obama";
tiga.city = "White House";
tiga.prevPtr = &dua;
std::cout << satu.prevPtr->name << std::endl; // lady gaga
std::cout << dua.prevPtr->name << std::endl; // luna maya
std::cout << tiga.prevPtr->name << std::endl; // barack obama
return 0;
}
#include <cstdlib>
struct data{
std::string name;
std::string city;
data *prevPtr;
};
int main(int argc, char *argv[]){
system("color 2f");
data zero;
zero.name = "Lady Gaga";
zero.city = "NYC";
zero.prevPtr = NULL;
data satu;
satu.name = "Luna Maya";
satu.city = "Denpasar";
satu.prevPtr = &zero;
data dua;
dua.name = "Bill Clinton";
dua.city = "Virginia";
dua.prevPtr = &satu;
data tiga;
tiga.name = "Barack Obama";
tiga.city = "White House";
tiga.prevPtr = &dua;
std::cout << satu.prevPtr->name << std::endl; // lady gaga
std::cout << dua.prevPtr->name << std::endl; // luna maya
std::cout << tiga.prevPtr->name << std::endl; // barack obama
return 0;
}
No comments:
Post a Comment