Skip to content

Instantly share code, notes, and snippets.

@madbence
Created April 16, 2013 19:51
Show Gist options
  • Save madbence/5399035 to your computer and use it in GitHub Desktop.
Save madbence/5399035 to your computer and use it in GitHub Desktop.
Szoftver laboratórium 2, 10. labor, szorgalmi
// ha T nem primitív típus
template<class T>
bool isPrimitiveType() { return false; }
// kivéve, ha pl int.
// a teljes megoldáshoz double, stb-re is meg kéne írni, ezért fapados kicsit :-)
template<>
bool isPrimitiveType<int>() { return true; }
// A módosított Array konstruktor
explicit Array(size_t n = maxsiz, const T& value = T()) : siz(0) {
if(isPrimitiveType<T>())
{
while (siz < n && siz < maxsiz)
t[siz++] = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment