No you don't delete it, you replace it.
See, filename.find() searches only the file's name, not the contents.
To search the contents, you use the string you passed in the second argument for getline(myfile, line).
Se replace filename.find() with line.find()
Ok, right now it's ignoring lines containing 'class' or '::' and counting everything else for object and method lines, right?
If you just want it to count when it encounters the string 'class' or '::' then you need to move objlines++ and methodlines++ into their respective if statements before the continue.
If I understand you correctly, you want to count how many objects and methods there are but NOT how many lines of code make them up, right?
If that's true, then yes, lose the continue and put the counter inside the if statement so it only counts when it encounters the string 'class' and '::'.
Oh, it counts class twice because it finds it twice. Once in the class declaration and once in the find function. That's a tough one. If you're searching this source file, no matter what you do you will always find one extra of what you're looking for.
I don't know, maybe someone more experienced than me will come along and help.
Also, I just noticed this, but find doesn't return a boolean value so use if(line.find() != line.npos) instead. And double quotes for a string, single quotes for a character.
Line 47 blows away filename. So when you try to open the file again at line 59, filename contains junk (specifically the last line of the program).
Line 49: '//' should be "//" (double quotes, not single). Also, what if the line is a = 1; // blah blah blah ? Without additional code, this will register as a comment, even though it also contains code.