/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
basic_content/struct/struct_func_func.cpp
35 строк
693 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
#include <iostream> #include <stdio.h> struct Base { int v1; // private: //error! int v3; public: // 显示声明public int v2; void print() { printf("%s\n", "hello world"); }; }; typedef struct Base1 { int v1; // private: //error! int v3; public: // 显示声明public int v2; void print() { printf("%s\n", "hello world"); }; } B; void Base() { printf("%s\n", "I am Base func"); } // void B() {} //error! 符号 "B" 已经被定义为一个 "struct Base1" 的别名 int main() { struct Base base; // ok // Base base1; // error! base.v1 = 1; base.v3 = 2; base.print(); printf("%d\n", base.v1); printf("%d\n", base.v3); Base(); return 0; }