TEMPLATE FOR USING POINTERS - I FIGURED IT OUT!!
This commit is contained in:
parent
0b9ea99c8c
commit
e0bafa7b17
@ -1,14 +1,12 @@
|
|||||||
void setCPU(){};
|
// void setCPU(){};
|
||||||
|
|
||||||
|
|
||||||
void setCPU(std::string mmodel, float mmainclock, float mboostclock) {
|
void setCPU(CPU *pCPU, float mmainclock) {
|
||||||
A7800x3d.mainclock = mmainclock;
|
|
||||||
A7800x3d.boostclock = mboostclock;
|
|
||||||
// model.boostclock = boostclock; // This doesnt work because its not a vaild reference!
|
|
||||||
// Trying to use the local model var to call the global CPU class for that specific model
|
|
||||||
cout << "Coming from the setCPU function in setcpu.h" << endl;
|
cout << "Coming from the setCPU function in setcpu.h" << endl;
|
||||||
cout << "\n\n\n" << mmodel << ".mainclock\n\n" << endl;
|
|
||||||
cout << "\n\n" << i75820k.boostclock << "\n\n" << endl;
|
pCPU->mainclock = mmainclock;
|
||||||
|
cout << "Incoming main clock variable was: " << mmainclock << endl;
|
||||||
|
|
||||||
cout << "Leaving setCPU()\n\n";
|
cout << "Leaving setCPU()\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
lists/cpu.h
18
lists/cpu.h
@ -2,24 +2,10 @@
|
|||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
CPU i75820k;
|
|
||||||
|
|
||||||
|
CPU *A7800x3d = new CPU;
|
||||||
|
CPU *Ii75820k = new CPU;
|
||||||
|
|
||||||
// Testing a function to create the class - cant access the class from main function though.
|
|
||||||
void a7800x3d(){
|
|
||||||
CPU A7800x3d;
|
|
||||||
cout << "Initial Main Clock: " << A7800x3d.mainclock << "\n" << A7800x3d.boostclock << endl;
|
|
||||||
};
|
|
||||||
|
|
||||||
void a7800x3d(float mainclock, float boostclock){
|
|
||||||
CPU A7800x3d;
|
|
||||||
A7800x3d.mainclock = mainclock;
|
|
||||||
A7800x3d.boostclock = boostclock;
|
|
||||||
|
|
||||||
std::cout << "Main clock is: " << A7800x3d.mainclock << "\nBoost clock is: " << A7800x3d.boostclock << endl;
|
|
||||||
|
|
||||||
// return mainclock, boostclock;
|
|
||||||
};
|
|
||||||
|
|
||||||
// std::string a7800x3d(std::string man){
|
// std::string a7800x3d(std::string man){
|
||||||
// CPU A7800x3d;
|
// CPU A7800x3d;
|
||||||
|
|||||||
@ -43,7 +43,6 @@ class CPU: public Hardware {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Spawn a CPU class for the Ryzen 7 7800x3d
|
// Spawn a CPU class for the Ryzen 7 7800x3d
|
||||||
CPU A7800x3d;
|
// CPU *A7800x3d; // Spawn a CPU class for the Intel i7 5820k
|
||||||
// Spawn a CPU class for the Intel i7 5820k
|
// CPU *Ii75820k;
|
||||||
CPU Ii75820k;
|
|
||||||
|
|
||||||
|
|||||||
36
main.cpp
36
main.cpp
@ -10,24 +10,44 @@ int main() {
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/* Error Checking
|
||||||
|
cout << "Main pointer address for A7800x3d: " << &A7800x3d << endl;
|
||||||
|
cout << "A7800x3d pointer before the value set is :" << &A7800x3d->manufacturer << endl;
|
||||||
|
cout << "A7800x3d value before change is: " << A7800x3d->manufacturer << endl;
|
||||||
|
A7800x3d->manufacturer = "AMD";
|
||||||
|
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl;
|
||||||
|
cout << "A7800x3d pointer after the change to AMD is: " << &A7800x3d->manufacturer << endl;
|
||||||
|
*/
|
||||||
|
A7800x3d->manufacturer = "AMD";
|
||||||
|
|
||||||
|
// Cat out both CPU's that have been created for sanity
|
||||||
|
cout << "IIi75820k manufacturer is: " << Ii75820k->manufacturer << endl;
|
||||||
|
cout << "A7800x3d manufacturer is: " << A7800x3d->manufacturer << endl;
|
||||||
|
|
||||||
|
cout << "Lets tyy the setCPU function!\n";
|
||||||
|
cout << "A7800x3d main clock speed is: " << A7800x3d->mainclock << endl;
|
||||||
|
|
||||||
|
setCPU(A7800x3d, 4.8);
|
||||||
|
cout << "A7800x3d new main clock speed is: " << A7800x3d->mainclock << endl;
|
||||||
|
|
||||||
// Set some variables for the spawned CPU's
|
// Set some variables for the spawned CPU's
|
||||||
A7800x3d.manufacturer = "AMD";
|
// A7800x3d.manufacturer = "AMD";
|
||||||
A7800x3d.model = "Ryzen 7 7800x3d";
|
// A7800x3d.model = "Ryzen 7 7800x3d";
|
||||||
|
|
||||||
i75820k.model = "i75820k";
|
// i75820k.model = "i75820k";
|
||||||
i75820k.manufacturer = "Intel";
|
// i75820k.manufacturer = "Intel";
|
||||||
|
|
||||||
setCPU("A7800x3d", 4.8, 5.2);
|
// setCPU("A7800x3d", 4.8, 5.2);
|
||||||
setCPU("i75820k", 3.2, 3.8);
|
// setCPU("i75820k", 3.2, 3.8);
|
||||||
// setCPU(A7800x3d, 4.8);
|
// setCPU(A7800x3d, 4.8);
|
||||||
|
|
||||||
|
/*
|
||||||
cout << "The " << A7800x3d.model << "'s Manufacturer is: " << A7800x3d.manufacturer << endl;
|
cout << "The " << A7800x3d.model << "'s Manufacturer is: " << A7800x3d.manufacturer << endl;
|
||||||
cout << "The Main Clock Speed is: " << A7800x3d.mainclock << endl;
|
cout << "The Main Clock Speed is: " << A7800x3d.mainclock << endl;
|
||||||
cout << "The Boost Clock Speed is: " << A7800x3d.boostclock << endl;
|
cout << "The Boost Clock Speed is: " << A7800x3d.boostclock << endl;
|
||||||
cout << "\n\nThe pointer is: " << ptr << endl;
|
cout << "\n\nThe pointer is: " << ptr << endl;
|
||||||
// cout << "The pointer is: " << *ptr.manufacturer << endl;
|
// cout << "The pointer is: " << *ptr.manufacturer << endl;
|
||||||
|
*/
|
||||||
system("sleep 3s");
|
system("sleep 3s");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user