34 lines
548 B
Plaintext
34 lines
548 B
Plaintext
Classes defined inside functions, called local classes, are only visible within those functions. They have advantages in some situations, but if they're just being used as functors, lambdas are preferred.
|
|
|
|
|
|
This rule raises an issue when a ``++class++`` or ``++struct++`` is defined inside a function.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
void doSomething() {
|
|
|
|
struct something { // Noncompliant
|
|
int a;
|
|
};
|
|
|
|
//...
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
struct something { // Noncompliant
|
|
int a;
|
|
};
|
|
|
|
void doSomething() {
|
|
|
|
//...
|
|
}
|
|
----
|
|
|