Constructor[생성자]

Tips/C++ Eng2015.11.28 23:18
  • Always have the same name as the class
  • Does not return anything
  • Use : syntax to initialize member variables


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "Rectangle.h"
 
/*
Rectangle(): _width{ 1 }, _height{ 1 }
{ }


*/


int main()
{
    int x;                        //garbage value
    int y{};
    int z{};
 
    Rectangle unintialized;   //garbage value
    Rectangle value{};
    Rectangle aggregate{ 2,3 };
 
    value._width = 2;
    value._height = 3;
}
cs


This contents comes from edx : Introduction to C++

'Tips > C++ Eng' 카테고리의 다른 글

How to use bitset in C++  (0) 2018.02.28
Constructor[생성자]  (0) 2015.11.28
Introducing Classes  (0) 2015.11.28
Storage classes and Scope  (0) 2015.11.23
Introducing the for Loop  (0) 2015.11.04
The Conditional (Ternary : 3중 조건문)  (0) 2015.11.04

작성자

Posted by 비타오백

관련 글

댓글 영역

티스토리 툴바