본문 바로가기

반응형

Programming

(117)
[C++ 실습] 4장-03. String 클래스 #include #include using namespace std; int main() { char charr1[20]; char charr2[20] = "jaguar"; string str1; string str2 = "panther"; cout > charr1; cout > str1; cout
[C++ 실습] 4장-02. 문자열 #include using namespace std; int main() { const int Size = 15; char name1[Size]; char name2[Size] = "C++owboy"; cout
[C++ 실습] 4장-01. 배열 #include using namespace std; int main() { int yams[3]; yams[0] = 7; yams[1] = 8; yams[2] = 6; int yamcosts[3] = { 200, 300, 50 }; cout
[C++] Chapter 11. Pointers and Dynamic Memory Management Pointer Array & Pointer Dynamic Memory Allocation Pointer Are designed to hold memory addresses as their vlaues a pointer contains the memory address Stack Memory vs Heap Memory Stack memory Compile time Assignment by Computer Heap Memory Runtime Assignment by Programmer Memory draw #include using namespace std; int main() { //Draw Memory contents //on the left hand side : address , in the middl..
[C++] Swap Function #include using namespace std; void swap_passByVal(int n1, int n2); void swap_passByRef(int& n1, int& n2); void swap_passByPtr(int* p1, int* p2); int main() { int num1 = 50, num2 = -60; cout
[C++] Chapater 7. Single-Dimensional Arrays and C-Strings Introducing Arrays a collection fo the same types of data int size = 4; double myList[size]; //Wrong const int size =4; double myList[size]; //Correct No Bound Checking C++ does not check array's boundary e.g., myList[-1] and myList[11] does not cause syntax errors dataType arrayName[arraySize]= {value0, value1, .... , valuek}; Wrong double myList[4]; myList={1.9, 2.9, 3.4, 3.5}; Implicit Size d..
[C++] Chapter 6. Functions funciton signature function overloading pass by value pass by reference pass by pointer function signature funciton name number of parameters type of parameters function overloading same name but not same number of parameters or type of parameters return type and pas-by-ref are not part of Function signature function Define a function function name number of parameters type of parameters Invoke ..
[C++] Chapter 2. Elementary Programming Reading Input from the keyboard use cin #include using namespace std; int main() { cout > Width; cout > Height; int area = Width * Height; cout

반응형