小编LOL*_*KFC的帖子

错误:成员访问不完整类型:转发声明

我在同一个.cpp上有两个类:

// forward
class B;

class A {       
   void doSomething(B * b) {
      b->add();
   }
};

class B {
   void add() {
      ...
   }
};
Run Code Online (Sandbox Code Playgroud)

前进不起作用,我无法编译.

我有这个错误:

error: member access into incomplete type 'B'
note: forward declaration of 'B'
Run Code Online (Sandbox Code Playgroud)

我正在使用clang编译器(clang-500.2.79).

我不想使用多个文件(.cpp和.hh),我想在一个.cpp上编码.

我不能在A班之前写B班.

你有什么想法解决我的问题吗?

最好的祝福.

c++ forward-declaration

37
推荐指数
2
解决办法
8万
查看次数

UNIX shell:按字长和ASCII顺序对字符串进行排序

我想按长度排序一个字符串,然后用ASCII顺序(大写和小写相等)用unix命令排序.

string = [a-z][A-Z][0-9]
Run Code Online (Sandbox Code Playgroud)

例如:

"A a b B cc ca cd" : 
=> A a b B
=> ca cc cd

"Hello stackoverflow how are you today"
=> are how you
=> Hello today
=> stackoverflow
Run Code Online (Sandbox Code Playgroud)

unix sorting shell awk command-line

7
推荐指数
1
解决办法
1295
查看次数

标签 统计

awk ×1

c++ ×1

command-line ×1

forward-declaration ×1

shell ×1

sorting ×1

unix ×1