Last active
January 26, 2022 22:35
-
-
Save gbrigens/fdc9e004e0852eec8da42e03810fe872 to your computer and use it in GitHub Desktop.
Pointers in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
struct Student { | |
string name; | |
int id; | |
int marks[3]; | |
}; | |
// Function prototype for getting details. | |
void getStudentDetails(Student* studentPointer); | |
void printStudentDetails(Student* studentPointer, int size); | |
int main() { | |
Student studentModel; // instantiating a student obj. | |
Student* studentPointer = &studentModel; // Define a pointer for the student obj. | |
// Note: You can send either studentPointer or &studentModel. They both refer to same address. | |
getStudentDetails(studentPointer); // Get data from the keyboard to instance and print the object. | |
return 0; | |
} | |
// Implement your solution. | |
void getStudentDetails(Student* studentPointer) { | |
} | |
void printStudentDetails(Student* studentPointer) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment