Remove trailing whitespaces
parent
04830f284c
commit
4e5d24464c
@ -1,44 +1,44 @@
|
|||||||
// classes are like structs, but everything is by default private.
|
// classes are like structs, but everything is by default private.
|
||||||
|
|
||||||
// Declaration
|
// Declaration
|
||||||
ObjectName className {
|
ObjectName className {
|
||||||
// Sets everything below it to be private.
|
// Sets everything below it to be private.
|
||||||
private:
|
private:
|
||||||
// Declaration of variables
|
// Declaration of variables
|
||||||
int a;
|
int a;
|
||||||
string b;
|
string b;
|
||||||
|
|
||||||
// Implement any private / helper functions below
|
// Implement any private / helper functions below
|
||||||
|
|
||||||
// Sets everything below it to be public.
|
// Sets everything below it to be public.
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
structName(new_a, new_b) {
|
structName(new_a, new_b) {
|
||||||
a = new_a;
|
a = new_a;
|
||||||
b = new_b;
|
b = new_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// accessors or getters functions
|
// accessors or getters functions
|
||||||
int getA() {
|
int getA() {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getB() {
|
string getB() {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mutators or setter functions
|
// mutators or setter functions
|
||||||
void setA(int new_a) {
|
void setA(int new_a) {
|
||||||
a = new_a;
|
a = new_a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setB(int new_b) {
|
void setB(int new_b) {
|
||||||
b = new_b;
|
b = new_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement any public functions below
|
// Implement any public functions below
|
||||||
};
|
};
|
||||||
|
|
||||||
// Accessing PUBLIC variables
|
// Accessing PUBLIC variables
|
||||||
ObjectName v = structName(5, "Hello"); // Creates a struct via the constructor
|
ObjectName v = structName(5, "Hello"); // Creates a struct via the constructor
|
||||||
std::cout << v.a << " " << v.b << std::endl; // Prints to console "5 Hello"
|
std::cout << v.a << " " << v.b << std::endl; // Prints to console "5 Hello"
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
// structs are like classes, but everything is by default public
|
// structs are like classes, but everything is by default public
|
||||||
|
|
||||||
// Declaration
|
// Declaration
|
||||||
ObjectName structName {
|
ObjectName structName {
|
||||||
|
|
||||||
// Declaration of variables
|
// Declaration of variables
|
||||||
int a;
|
int a;
|
||||||
string b;
|
string b;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
structName(new_a, new_b) {
|
structName(new_a, new_b) {
|
||||||
a = new_a;
|
a = new_a;
|
||||||
b = new_b;
|
b = new_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement any public functions below
|
// Implement any public functions below
|
||||||
};
|
};
|
||||||
|
|
||||||
// Accessing PUBLIC variables
|
// Accessing PUBLIC variables
|
||||||
ObjectName v = structName(5, "Hello"); // Creates a struct via the constructor
|
ObjectName v = structName(5, "Hello"); // Creates a struct via the constructor
|
||||||
std::cout << v.a << " " << v.b << std::endl; // Prints to console "5 Hello"
|
std::cout << v.a << " " << v.b << std::endl; // Prints to console "5 Hello"
|
||||||
|
Loading…
Reference in New Issue