//BEGIN: HEADER FILE
class TestClass
{
public:
TestClass() : pp(0), val(0), s(200) {}
void calc(int i);
void containsLoop();
private:
int pp;
int val;
int s;
};
//END: HEADER FILE
//BEGIN: IMPLEMENTATION FILE
//You need to add all the member variables that you use as pass-by-reference parameters
//The compiler will check if it makes sense to inline
static inline void calcStaticImpl(const int i, int &pp, int &val, int &s)
{
pp = (i + val) * 200 / s;
//etc
}
void TestClass::calc(int i)
{
calcStaticImpl(i, pp, val, s);
}
static const int NUMBER = 10000;
void TestClass::containsLoop()
{
for (int j = 0; j < NUMBER; ++j) {
for (int i = 0; i < NUMBER; ++i) {
calcStaticImpl(i, pp, val, s);
}
}
}
int main(int argc, char* argv[])
{
TestClass test;
test.calc(1);
test.containsLoop();
return 0;
}
//BEGIN: HEADER FILE
class TestClass
{
public:
TestClass() : pp(0), val(0), s(200) {}
void calc(int i);
void containsLoop();
private:
int pp;
int val;
int s;
};
//END: HEADER FILE
//BEGIN: IMPLEMENTATION FILE
//You need to add all the member variables that you use as pass-by-reference parameters
//The compiler will check if it makes sense to inline
static inline void calcStaticImpl(const int i, int &pp, int &val, int &s)
{
pp = (i + val) * 200 / s;
//etc
}
void TestClass::calc(int i)
{
calcStaticImpl(i, pp, val, s);
}
static const int NUMBER = 10000;
void TestClass::containsLoop()
{
for (int j = 0; j < NUMBER; ++j) {
for (int i = 0; i < NUMBER; ++i) {
calcStaticImpl(i, pp, val, s);
}
}
}
int main(int argc, char* argv[])
{
TestClass test;
test.calc(1);
test.containsLoop();
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks