목록전체 글 (351)
printf("ho_tari\n");
#include #include "square.h" #define SQUARE(num) (num) * (num) /* int square(int num) { return num * num; } */ int main(void) { //int result = square(5); //int result = SQUARE(5); // int result = (5) * (5); int i = 5; int result = square(i++); //int result = SQUARE(i++); // int result = (i++) * (i++); printf("result : %d\n", result); return 0; } #ifndef SQUARE_H #define SQUARE_H extern inline in..
#include #include "complex.h" int main() { Complex c1(3.0, 4.0); // (3.0, 4.0i) Complex c2(3.0); // (3.0, 0.0i) //Complex c2 = 3.0; // implicit conversion good! Complex c3; // (0.0, 0.0i) const Complex c4 = c1; c2 = c1; c2.real(c1.real()); c2.imag(c1.imag()); std::cout
#include #define SQUARE(num) (num) * (num) int square(int num) { return num * num; } int main(void) { //int result = square(5); //int result = SQUARE(5); // int result = (5) * (5); int i = 5; //int result = square(i++); int result = SQUARE(i++); // int result = (i++) * (i++); printf("result : %d\n", result); return 0; }
#include #include "string.h" int main() { String s1; String s2 = "hello, world"; // String s2("hello, world"); //String s2 = 0; String s3 = s2; // String s3(s2); s1 = s2; // s1 = s1; // self assignment?? s1 = "hello, "; // String tmp("hello, "); s1 = tmp; tmp.~String(); String s4 = " IoT"; s1 = s2 + s4; if (s1 == s2) { std::cout
#include #include "shape.h" #include "rectangle.h" #include "circle.h" #include void printArea(const Shape *ps) { std::cout
#include int main(void) { int a = 0x12345678; //int *p; char *p; //p = static_cast(&a); p = reinterpret_cast(&a); printf("*p : 0x%x\n", *p); return 0; }
#include int main(void) { int man, woman; printf("Man: "); scanf("%d", &man); printf("Woman: "); scanf("%d", &woman); double manratio, womanratio; manratio = static_cast(man) / (man + woman) * 100; womanratio = static_cast(woman) / (man + woman) * 100; printf("----------------------------\n"); printf("Ratio of Man : %.2f%%\nRatio of Woman : %.2f%%\n", manratio, womanratio); return 0; }