Add vectors and memory
This commit is contained in:
BIN
CM2005 Object Oriented Programming/Topic 4/4.3.1/a.exe
Normal file
BIN
CM2005 Object Oriented Programming/Topic 4/4.3.1/a.exe
Normal file
Binary file not shown.
23
CM2005 Object Oriented Programming/Topic 4/4.3.1/topic4.cpp
Normal file
23
CM2005 Object Oriented Programming/Topic 4/4.3.1/topic4.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
//using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
//vector<string> a;
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back("one");
|
||||
strings.push_back("two");
|
||||
strings.push_back("three");
|
||||
// we use const because we won't mutate the data in the s variable
|
||||
// Because we're only reading, we don't want to create a copy
|
||||
// so we use a reference '&' instead
|
||||
for (const std::string& s:strings)
|
||||
{
|
||||
std::cout << s << std::endl;
|
||||
std::string lel = "lol";
|
||||
//s.append(lel); // we can't use this because s is of type const
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user