Skip to content

Instantly share code, notes, and snippets.

@webber2408
Created April 12, 2020 06:26
Show Gist options
  • Save webber2408/7af3807cc989f3482c09141b6e019bb8 to your computer and use it in GitHub Desktop.
Save webber2408/7af3807cc989f3482c09141b6e019bb8 to your computer and use it in GitHub Desktop.
Structs in C++
#include<iostream>
using namespace std;
struct Country{
string name;
int populationCount;
Country(string s, int n){
name = s;
populationCount = n;
}
void showCountryDetails(){
cout<<"Country Name: "<<name<<endl;
cout<<"Country Population: "<<populationCount<<endl;
}
};
int main(){
struct Country c1 = Country("India", 1300000000);
c1.showCountryDetails();
return 0;
}
/*
Output:
Country Name: India
Country Population: 1300000000
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment