Reputation: 31
I have a code like:
class <name>
{
public:
...
private:
...
};
I want to ensure that the public section is declared before the private section and not after that.One way of doing this in Python is by comparing the line numbers where these words occur.However,am not sure if this would work when I have several such sections(such declarations) in my code.Any other suggestions?
Upvotes: 0
Views: 115
Reputation: 612894
This problem is, in general, much harder than you think. Not all classes are laid out like that.
private
sections and rely on the default visibility.private
and/or public
sections.And so on. To do this properly and reliably you need a proper C++ parser which is notoriously hard to get right. Don't try to implement one of those yourself using simple text search.
Upvotes: 4