CPP0X_Base 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
main.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* main.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/04/26 16:33:16 by kamitsui #+# #+# */
9/* Updated: 2025/05/01 23:51:21 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
17#include "Example.hpp"
18#include <iostream>
19#include <string>
20
31int main(int argc, char **argv) {
32 Example defaultExample;
33 std::cout << "main (default): ";
34 defaultExample.printMessage();
35
36 Example customExample("Greetings from main!");
37 std::cout << "main (custom): ";
38 customExample.printMessage();
39
40 useExampleClass(defaultExample, "Message changed in main!");
41 useExampleClass(customExample, "Another message!");
42
43 (void)argc;
44 (void)argv;
45 return 0;
46}
Example クラスの定義
void useExampleClass(Example &exampleObj, const std::string &newMessage)
Example クラスのインスタンスを作成し、メッセージを設定して出力します。
Example クラス
Definition Example.hpp:29
void printMessage() const
メッセージを出力します。
Definition Example.cpp:28
int main(int argc, char **argv)
メイン関数
Definition main.cpp:31