
u1401_1.cpp
#include <iostream>
int main() {
#if -1 > 0
std::cout << "mm"
<< std::endl;
#elif 1 > 0
std::cout << "ok"
<< std::endl;
#else
std::cout << "xx"
<< std::endl;
#endif
return 0;
}
/* Kaiching Chang
u1401_1.cpp
2014-02 */u1401_2.cpp
#include <iostream>
#define DEMO1 10
int main() {
#ifdef DEMO1
std::cout << "demo1"
<< std::endl;
#else
std::cout << "no demo1"
<< std::endl;
#endif
#ifndef DEMO2
std::cout << "no demo2"
<< std::endl;
#else
std::cout << "demo2"
<< std::endl;
#endif
return 0;
}
/* Kaiching Chang
u1401_2.cpp
2014-02 */u1402_1.cpp
#include <iostream>
#define DEMO 10
int main() {
std::cout << DEMO
<< std::endl;
#undef DEMO
//std::cout << DEMO
// << std::endl;
return 0;
}
/* Kaiching Chang
u1402_1.cpp
2014-02 */u1402_2.cpp
#include <iostream>
#define Prints(arg) std::cout << #arg
int main() {
Prints(hello);
std::cout << std::endl;
return 0;
}
/* Kaiching Chang
u1402_2.cpp
2014-02 */u1402_3.cpp
#include <iostream>
#define F(n, a) int f##n() {return a;}
F(test, 0);
F(function, 1);
F(rrr, 2);
int main() {
std::cout << ftest()
<< std::endl;
std::cout << ffunction()
<< std::endl;
std::cout << frrr()
<< std::endl;
return 0;
}
/* Kaiching Chang
u1402_3.cpp
2014-02 */u1403_1.cpp
#include <iostream>
#include <string>
int main() {
std::string s = "There is no spoon.";
std::cout << s.find("no")
<< std::endl;
return 0;
}
/* Kaiching Chang
u1403_1.cpp
2014-02 */u1403_2.h
class Demo {
public:
int a;
int b;
int do_something();
};
/* Kaiching Chang
u1403_2.h
2014-02 */u1403_2.cpp
#include <iostream>
#include "u1403_2.h"
int Demo::do_something() {
return a + b;
}
int main() {
Demo d;
d.a = 1;
d.b = 2;
std::cout << d.do_something()
<< std::endl;
return 0;
}
/* Kaiching Chang
u1403_2.cpp
2014-02 */the end
沒有留言:
張貼留言