labs-edaf30/lab4/toString_test.cc

23 lines
648 B
C++
Raw Normal View History

2024-12-11 15:54:56 +01:00
#include <iostream>
#include "date.h" // Inkludera Date-klassen från tidigare lösning
#include "toString.h" // Inkludera toString-mallen
int main() {
// Testa med ett primitivt datatyper
double d = 1.234;
int i = 42;
std::string strDouble = toString(d);
std::string strInt = toString(i);
std::cout << "Double as string: " << strDouble << std::endl;
std::cout << "Integer as string: " << strInt << std::endl;
// Testa med Date-klassen
Date today(2023, 12, 11); // Skapa ett datumobjekt
std::string strDate = toString(today);
std::cout << "Date as string: " << strDate << std::endl;
return 0;
}