Skip to content

Commit 61254b8

Browse files
authored
Merge pull request #10 from XuhuaHuang/develop
Develop
2 parents 264600e + 7bf3c3b commit 61254b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+404
-148
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
mono_crash.*
3030

3131
# Build results
32+
# Qt build results
33+
build*Qt*-Debug/
34+
build*Qt*-Profile/
35+
build*Qt*-Release/
36+
*.qmake.*
3237
[Dd]ebug/
3338
[Dd]ebugPublic/
3439
[Rr]elease/

BitwiseOperator/BitwiseOperator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
void print(const int& value)
1212
{
13-
std::cout << value << std::endl;
13+
std::cout << value << "\n";
1414
}
1515

1616
int main(void)
@@ -24,4 +24,4 @@ int main(void)
2424
print(a >> 2);
2525
print((a >> 2) & 1);
2626
return 0;
27-
}
27+
}

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(HelloWorld LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
add_executable(HelloWorld "Miscellaneous/hello_world.cpp" "LICENSE.md" "README.md")

Demonstration/__func__.cpp renamed to CompilerMacro/__func__.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main(void)
6060
{
6161
/* Test __func__ predefined macro */
6262
std::cout << hello() << "\n"
63-
<< world() << std::endl;
63+
<< world() << "\n";
6464
LOG("Function call hello() returns: %s", hello());
6565
LOG("Function call world() returns: %s", world());
6666

@@ -75,4 +75,4 @@ int main(void)
7575

7676
system("pause");
7777
return 0;
78-
}
78+
}

CompilerMacro/macro_expansion.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*****************************************************************//**
2+
* \file macro_expansion.cpp
3+
* \brief Macro expansion in C++
4+
*
5+
* \author Xuhua Huang
6+
* \date November 2022
7+
*********************************************************************/
8+
9+
#include <iostream>
10+
11+
#define M(x, y, z) x*y+z
12+
13+
int main(void)
14+
{
15+
int a = 1, b = 2, c = 3;
16+
int sum = M(a+b, b+c, a+c);
17+
18+
// M(a, b, a) = M(1, 2, 1) = 3
19+
// M(b, c, c) = M(2, 3, 3) = 9
20+
std::cout << "sum = " << sum << "\n";
21+
22+
return 0;
23+
}

Demonstration/demo_constexpr.cpp renamed to Constexpr/demo_constexpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ void demo_constexpr(const int arg) {
6565
return;
6666
}
6767

68-
int main(void) {
68+
auto main(void) -> int {
6969
int temp_const = get_const();
70-
std::cout << "Value of temp_const: " << temp_const << std::endl;
70+
std::cout << "Value of temp_const: " << temp_const << "\n";
7171

7272
demo_constexpr(1);
7373
demo_constexpr(2);
7474

7575
system("pause");
76-
return 0;
77-
}
76+
return EXIT_SUCCESS;
77+
}

Demonstration/demo_is_multiple_of.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "../Util/log.h"
2121

2222
#ifndef DEBUG
23-
#define DEBUG(str) std::cout << str << std::endl;
23+
#define DEBUG(str) std::cout << str << "\n";
2424
#endif
2525

2626
/**

Demonstration/winAPI_GetCommandLineA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
int main(void)
1616
{
17-
std::cout << GetCommandLineA() << std::endl;
17+
std::cout << GetCommandLineA() << "\n";
1818

1919
char* const pBuf = GetCommandLineA();
2020
if (pBuf != nullptr)
@@ -57,4 +57,4 @@ int main(void)
5757
}
5858

5959
return 0;
60-
}
60+
}

FunctionPointer/function_pointers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void printValue(const int value)
4040
*
4141
* \param value: constant copy of an int
4242
*/
43-
std::cout << "[fn][void printValue(int)]Content: " << value << std::endl;
43+
std::cout << "[fn][void printValue(int)]Content: " << value << "\n";
4444
}
4545

4646
int main(void)
@@ -74,7 +74,7 @@ int main(void)
7474
ForEach(values, [](int value) { // start lambda
7575
// capture all integers in scope by copying
7676
// no trailing return
77-
std::cout << "[lambda][&](int value)Value: " << value << std::endl;
77+
std::cout << "[lambda][&](int value)Value: " << value << "\n";
7878
} // end lambda
7979
);
8080

HackerRank/VirtualFunctions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Professor : public Person
5454

5555
void putdata(void) override {
5656
Person::putdata();
57-
std::cout << " " << this->publications << " " << this->cur_id << std::endl;
57+
std::cout << " " << this->publications << " " << this->cur_id << "\n";
5858
}
5959
};
6060

@@ -85,7 +85,7 @@ class Student : public Person
8585

8686
void putdata(void) override {
8787
Person::putdata();
88-
std::cout << " " << this->sum << " " << this->cur_id << std::endl;
88+
std::cout << " " << this->sum << " " << this->cur_id << "\n";
8989
}
9090
};
9191

@@ -117,4 +117,4 @@ int main() {
117117
per[i]->putdata(); // Print the required output for each object.
118118

119119
return 0;
120-
}
120+
}

0 commit comments

Comments
 (0)