• 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' 카테고리의 다른 글

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
switch Statments  (0) 2015.11.04

WRITTEN BY
Profile
비타오백
Enjoy your stage!

받은 트랙백이 없고 , 댓글이 없습니다.
secret