Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

assign a struct to another c++

#include <iostream>
#include <string>

using namespace std;

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

int main(){
    car c1 = {"BMW", "Red", 250, 2022};
    car c2 = c1;			//assigning struct c1 to struct c2
}
 
PREVIOUS NEXT
Tagged: #assign #struct
ADD COMMENT
Topic
Name
3+7 =