From 1f8cafa30cc5925afcf6e6c8ee9c238bbc8be016 Mon Sep 17 00:00:00 2001 From: ganome Date: Tue, 28 Jan 2025 12:17:10 -0700 Subject: [PATCH] playing with functions inside of headers --- lists/cpu.h | 20 ++++++++++++++------ lists/hardware.h | 10 +++++----- main.cpp | 26 +++++++++++++------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/lists/cpu.h b/lists/cpu.h index ef2156d..8adbce2 100644 --- a/lists/cpu.h +++ b/lists/cpu.h @@ -1,10 +1,18 @@ #pragma once #include "hardware.h" -CPU A7800x3d; -A7800x3d.manufacturer = "AMD"; -A7800x3d.ReleasedYear = 2024; -A7800x3d.architecture = "Zen 4"; -A7800x3d.boostclock = 5.2; -A7800x3d.mainclock = 4.8; +void a7800x3d(){CPU A7800x3d;}; + +float a7800x3d(float mainclock, float boostclock){ + CPU A7800x3d; + A7800x3d.mainclock = mainclock; + A7800x3d.boostclock = boostclock; + return mainclock,boostclock; +}; + +std::string a7800x3d(std::string man){ + CPU A7800x3d; + A7800x3d.manufacturer = "AMD"; + return man; +}; diff --git a/lists/hardware.h b/lists/hardware.h index cfbda51..28e52b8 100644 --- a/lists/hardware.h +++ b/lists/hardware.h @@ -26,11 +26,11 @@ class CPU: public Hardware { }; }; -std::string a7800x3d(std::string man){ - CPU A7800x3d; - A7800x3d.manufacturer = "AMD"; - return man; -}; +// std::string a7800x3d(std::string man){ + // CPU A7800x3d; + // A7800x3d.manufacturer = "AMD"; + // return man; +// }; // CPU A7800x3d; // A7800x3d.manufacturer = "AMD"; diff --git a/main.cpp b/main.cpp index be384b2..9e6afc9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,25 +1,25 @@ #include #include #include "lists/hardware.h" - -// std::string a7800x3d(std::string man){ - // CPU A7800x3d; - // A7800x3d.manufacturer = "AMD"; - // return man; -// }; +#include "lists/cpu.h" int main() { using namespace std; - // CPU A7800x3d; - // A7800x3d.manufacturer = "AMD"; - // A7800x3d.ReleasedYear = 2024; - // A7800x3d.architecture = "Zen 4"; - // A7800x3d.boostclock = 5.2; - // A7800x3d.mainclock = 4.8; +/* Trying to declare a class with name A7800x3d + CPU A7800x3d; + A7800x3d.manufacturer = "AMD"; + A7800x3d.ReleasedYear = 2024; + A7800x3d.architecture = "Zen 4"; + A7800x3d.boostclock = 5.2; + A7800x3d.mainclock = 4.8; +*/ +// referencing the function a7800x3d from cpu.h + a7800x3d("AMD"); - cout << a7800x3d("AMD"); + cout << "Setting 7800x3d Manufacturer to AMD : " << a7800x3d("test") << endl; + cout << "Setting the clock speeds to: Main: " << a7800x3d(4.8,5.2) << endl; // cout << "The Manufacturer is: " << A7800x3d.manufacturer << endl; // cout << "The Main Clock Speed is: " << A7800x3d.mainclock << endl;