Back
Close

Computing with Data

elgeish
33.5K views

Structs - Part II

#include <iostream>
#include <string>
using namespace std;
struct Person {
string name;
double age;
};
void by_address_of_const(const Person *p) {
Person x;
p = &x;
cout << "modified copy inside function: " << p << endl;
}
int main() {
Person person;
Person *pointer = &person;
cout << "before function call: " << pointer << endl;
by_address_of_const(pointer);
cout << "after function call: " << pointer << endl;
return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants