array of
Array.of(7); // [7]
Array.of(1, 2, 3); // [1, 2, 3]
Array(7); // [ , , , , , , ]
Array(1, 2, 3); // [1, 2, 3]
array of
Array.of(7); // [7]
Array.of(1, 2, 3); // [1, 2, 3]
Array(7); // [ , , , , , , ]
Array(1, 2, 3); // [1, 2, 3]
array of function
#include <iostream>
using namespace std;
class fish
{
public:
fish();
int getAge() {return age;}
void setAge(int newage) { age = newage; }
private:
int age;
};
fish::fish()
{
age = 0;
}
void showAges(fish fishes[])
{
cout << "fish 1 age is: " << fishes[0].getAge() << endl;
cout << "fish 2 age is: " << fishes[1].getAge() << endl;
cout << "fish 3 age is: " << fishes[2].getAge() << endl;
}
int main()
{
fish myFish[3];
showAges(myFish);
cout << endl;
myFish[0].setAge(10);
myFish[1].setAge(20);
myFish[2].setAge(30);
showAges(myFish);
cin.get();
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us