Skip to content

Instantly share code, notes, and snippets.

@Utshaw
Created February 16, 2025 20:15
Show Gist options
  • Save Utshaw/3552b4bcb1f1785209f774f3ef906926 to your computer and use it in GitHub Desktop.
Save Utshaw/3552b4bcb1f1785209f774f3ef906926 to your computer and use it in GitHub Desktop.
Pointer helps solve issues
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<vector<int>*> starship;
vector<int> midship;
midship.push_back(50);midship.push_back(80);midship.push_back(40);midship.push_back(45);
vector<int> smallship;
smallship.push_back(10);smallship.push_back(6);smallship.push_back(4);smallship.push_back(8);
starship.push_back(&midship);starship.push_back(&smallship);
int ship_id = 0;
midship.at(2) = 99;
for(auto power : midship) {
cout << power << " " ;
}
cout << endl;
for (auto ship : starship) {
cout << "Ship#" << ship_id+1 << endl;
cout << "________________________________" << endl;
for (int power : *ship) {
cout << power << " " ;
}
cout << endl << endl << endl;
ship_id += 1;
}
return 0;
}

Comments are disabled for this gist.