将“class”更改为“struct”

时间:2011-06-15 13:14:54

标签: c++ c

我需要将struct“class”更改为“struct normal”,以便于阅读源代码。可以将代码开头的“class”更改为 Program to create a queue using dynamic memory allocation 中源代码中的“struct”。

2 个答案:

答案 0 :(得分:2)

很难理解你的问题到底是什么。 C ++中的structclass相同,但成员默认为public而不是private

如果你有一个struct而你想让它成为class,你可以这样做:

struct Thing {
  // ...
};

// Change this to:
class Thing {
public:
  // ...
};

或者,相反,classstruct

class Thing {
  // ...
};

// Change this to:
struct Thing {
private:
  // ...
};
然而,我并没有看到一个人如何比另一个更“可读”。

答案 1 :(得分:1)

将类更改为struct =

1) Find a "Find and Replace" button in your IDE or text editor
2) In Find What field enter class
3) In Replace With field enter struct
4) click Replace All 

是的,这是一个糟糕的答案,但问题也是如此:)