Created
September 8, 2017 14:08
-
-
Save kaworu/33fd113f0a8e0e481bb936b8cc2205f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Rack { | |
public: | |
Rack(int i): m_i(i) | |
{ } | |
int geti() | |
{ | |
return m_i; | |
} | |
protected: | |
int m_i; | |
}; | |
void | |
do_something_with_racks(Rack *list[], size_t len) | |
{ | |
for (size_t i = 0; i < len; i++) | |
std::cout << list[i]->geti() << std::endl; | |
} | |
int | |
main(int argc, char **argv) | |
{ | |
Rack one(1); | |
Rack answer(42); | |
Rack vegeta(9001); | |
Rack *list[] = {&one, &answer, &vegeta}; | |
do_something_with_racks(list, (sizeof(list) / sizeof(*list))); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment