Search
 
SCRIPT & CODE EXAMPLE
 

CPP

struct and return functions in c++

#include <iostream>
#include <string>

using namespace std;

struct car{
    string name;
    string color;
    int maxSpeed;
    int model;
};

car fun (car &x){
    cout << "Name: " ;
    cin >> x.name;
    cout << "Model: ";
    cin >> x.model;
    cout << "Color: ";
    cin >> x.color;
    cout << "Maximum speed: ";
    cin >> x.maxSpeed;
    return x;
}

int main(){
    car c1;
    fun (c1);
    car c2 = c1;
    cout << "Name: " << c2.name <<endl;
    cout << "Model: " << c2.model <<endl;
    cout << "Color: " << c2.color <<endl;
    cout << "Maximum speed: " << c2.maxSpeed <<endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: compute the average of an array c++ 
Cpp :: c++ hello world program 
Cpp :: compile multiple files C++ linux 
Cpp :: cpp how to input a variable without hitting enter 
Cpp :: c++ write to file 
Cpp :: rotation to vector2 godot 
Cpp :: fill two dimension array c++ 
Cpp :: g++ -wall option meaning 
Cpp :: c++ fast 
Cpp :: dev c++ tahe last word error 
Cpp :: sfml mouse click 
Cpp :: screen record ios simulator 
Cpp :: perulangan c++ 
Cpp :: cpp code for euclids GCD 
Cpp :: std::tuple apply multiplier 
Cpp :: print 5 table in c++ 
Cpp :: c++ check open processes 
Cpp :: delete specific vector element c++ 
Cpp :: oncomponentbeginoverlap ue4 c++ 
Cpp :: convert vector into array c++ 
Cpp :: how to delete a certain amount of numbers of the same value in multiset c++ 
Cpp :: cpp goiver all the map values 
Cpp :: c++ random 
Cpp :: c++ unordered_map check if key exists 
Cpp :: min element c++ 
Cpp :: convert long int to binary string c++ 
Cpp :: gfgdf 
Cpp :: how to do nCr in c++ 
Cpp :: string reverse stl 
Cpp :: print all elements of vector c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =