add programs for namespaces and function stuff
This commit is contained in:
parent
b1ac6cfb47
commit
c27c685712
4 changed files with 49 additions and 1 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"editor.detectIndentation": false,
|
||||
"editor.insertSpaces": false
|
||||
"editor.insertSpaces": false,
|
||||
}
|
||||
|
|
|
@ -5,3 +5,5 @@ add_executable(sqrt sqrt.cc)
|
|||
target_link_libraries(sqrt PRIVATE Math)
|
||||
add_executable(inheritance inheritance.cc)
|
||||
add_executable(enumerations enumerations.cc)
|
||||
add_executable(namespaces namespaces.cc)
|
||||
add_executable(functions functions.cc)
|
||||
|
|
31
src/functions.cc
Normal file
31
src/functions.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void sus(std::string susValue, std::string& susReference)
|
||||
{
|
||||
susValue = "sus?";
|
||||
susReference = "sussy?";
|
||||
|
||||
std::cout << "sus(std::string susValue, std::string& susReference) has ran" << std::endl;
|
||||
}
|
||||
|
||||
void print_string(std::string nameOf, std::string& string)
|
||||
{
|
||||
std::cout << "The value of " << nameOf << " is " << string << std::endl;
|
||||
}
|
||||
|
||||
void print_sussy_strings(std::string& sus1, std::string& sus2)
|
||||
{
|
||||
print_string("sus1", sus1);
|
||||
print_string("sus2", sus2);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string sus1 = "this is the first sussy string";
|
||||
std::string sus2 = "this is the second sussy string";
|
||||
|
||||
print_sussy_strings(sus1, sus2);
|
||||
sus(sus1, sus2);
|
||||
print_sussy_strings(sus1, sus2);
|
||||
}
|
15
src/namespaces.cc
Normal file
15
src/namespaces.cc
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace Imposter {
|
||||
class Namespace {
|
||||
public:
|
||||
static void sussy_function() {
|
||||
std::cout << "This is a sus function." << std::endl;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main() {
|
||||
Imposter::Namespace::sussy_function();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue