No need for an empty constructor in C++11:
Array() { }
You can just use a
default
constructor:Array() = default;
It's a little confusing to have multiple
public
/private
sections. Here, you can just put all thepublic
code under the same keyword.You could make your structure more useful by providing iterators. This will, for instance, allow you to use range based
for
-loops instead of plain ones for iterating through this structure.You don't need
std::endl
if you just need newlines. Just output"\n"
instead for this. More info about this can be found here here.It's unnecessary to have your own
return 0
at the end ofmain()
in C++. The compiler will provide this return for you.
No need for an empty constructor in C++11:
Array() { }
You can just use a
default
constructor:Array() = default;
It's a little confusing to have multiple
public
/private
sections. Here, you can just put all thepublic
code under the same keyword.You could make your structure more useful by providing iterators. This will, for instance, allow you to use range based
for
-loops instead of plain ones for iterating through this structure.You don't need
std::endl
if you just need newlines. Just output"\n"
instead for this. More info about this can be found here.It's unnecessary to have your own
return 0
at the end ofmain()
in C++. The compiler will provide this return for you.
No need for an empty constructor in C++11:
Array() { }
You can just use a
default
constructor:Array() = default;
It's a little confusing to have multiple
public
/private
sections. Here, you can just put all thepublic
code under the same keyword.You could make your structure more useful by providing iterators. This will, for instance, allow you to use range based
for
-loops instead of plain ones for iterating through this structure.You don't need
std::endl
if you just need newlines. Just output"\n"
instead for this. More info about this can be found here.It's unnecessary to have your own
return 0
at the end ofmain()
in C++. The compiler will provide this return for you.
No need for an empty constructor in C++11:
Array() { }
You can just use a
default
constructor:Array() = default;
It's a little confusing to have multiple
public
/private
sections. Here, you can just put all thepublic
code under the same keyword.You could make your structure more useful by providing iterators. This will, for instance, allow you to use range based
for
-loops instead of plain ones for iterating through this structure.You don't need
std::endl
if you just need newlines. Just output"\n"
instead for this. More info about this can be found here.It's unnecessary to have your own
return 0
at the end ofmain()
in C++. The compiler will provide this return for you.