Today, I found a warning when I was writing a C + + program. After thinking about it, I found the answer on the Internet. Well, there is something wrong with the order
class A
{
public:
A(int a, int b);
private:
int two;
int one;
};
A::A(int a, int b):one(a),two(b)
{
};
In the G + + compiler, there will be warnings when compiling:
warning: 'A::one' will be initialized after [-Wreorder]
The main problem is the order (pay attention to the order of one and two), that is, the order of members in the initialization list and the order of members in the class must be consistent, so that there will be no warning again. Change the above code:
class A
{
public:
A(int a, int b);
private:
int one;
int two;
};
A::A(int a, int b):one(a),two(b)
{
};
Similar Posts:
- Convert Object to List>, avoiding Unchecked cast: ‘java.lang.Object’ to ‘java.util.List
- Warning: The serializable class * does not declare a static final serialVersionUID
- [Problems with the use of internal classes] No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclo
- error: invalid storage class for function
- sorry, unimplemented: non-trivial designated initializers not supported
- Consider defining a bean of type ‘xxx’ in your configuration. Autowired(required=true)
- How to Solve JAVA @override error
- [Solved] SpringBoot Startup Error: is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
- [Solved] Error: `resize` should not be called during main process.
- Vs generation fails without error [How to Solve]