diff options
-rw-r--r-- | 7p35.cpp | 5 | ||||
-rw-r--r-- | 7p36.cpp | 17 | ||||
-rw-r--r-- | 7p37.cpp | 32 | ||||
-rw-r--r-- | 7p38.cpp | 30 | ||||
-rw-r--r-- | 7p39.cpp | 11 | ||||
-rw-r--r-- | 7p40.cpp | 40 |
6 files changed, 130 insertions, 5 deletions
@@ -1,12 +1,10 @@ #include <iostream> - /* * * 7.35 * * */ - typedef std::string Type; Type initVal(); class Exercise { @@ -17,16 +15,13 @@ public: private: int val; }; - Exercise::Type Exercise::setVal(Exercise::Type parm) { val = parm + initVal(); // double initVal() is used return val; // Return val as double? } - Exercise::Type Exercise::initVal() { return 0; } - int main () { return 0; } diff --git a/7p36.cpp b/7p36.cpp new file mode 100644 index 0000000..6f886fc --- /dev/null +++ b/7p36.cpp @@ -0,0 +1,17 @@ + +/* + * + * 7.36 + * + * + */ + +struct X { + X (int i, int j): base(i), rem(i % j) { } + int base, rem; +}; + +int main () { + + return 0; +} diff --git a/7p37.cpp b/7p37.cpp new file mode 100644 index 0000000..6a46131 --- /dev/null +++ b/7p37.cpp @@ -0,0 +1,32 @@ + +/* + * + * 7.37 + * + * + */ + +/* +class Sales_data { +public: + // defines the default constructor as well as one that takes a string argument + Sales_data(std::string s = ""): bookNo(s) { } + // remaining constructors unchanged + Sales_data(std::string s, unsigned cnt, double rev): + bookNo(s), units_sold(cnt), revenue(rev*cnt) { } + Sales_data(std::istream &is) { read(is, *this); } + // remaining members as before +}; +*/ + +/* + Sales_data first_item(cin); // Sales_data(std::istream &is) { read(is, *this); } + int main() { + Sales_data next; // Sales_data(std::string s = ""): bookNo(s) { } + Sales_data last("9-999-99999-9"); // Sales_data(std::string s = ""): bookNo(s) { } +} + */ + +int main () { + return 0; +} diff --git a/7p38.cpp b/7p38.cpp new file mode 100644 index 0000000..21a6a8e --- /dev/null +++ b/7p38.cpp @@ -0,0 +1,30 @@ +#include <iostream> + +/* + * + * 7.38 + * + * Not exactly 100% sure what i was supposed to do but here it is. + */ + +class ch7e738 { +public: + ch7e738(std::istream& in) { + in >> i; + } + + std::ostream& printmemb(std::ostream& pmcout) { + pmcout << i; + return pmcout; + } + +private: + int i; +}; + +int main () { + + ch7e738 s(std::cin); + s.printmemb(std::cout) << std::endl; + return 0; +} diff --git a/7p39.cpp b/7p39.cpp new file mode 100644 index 0000000..d8d02c0 --- /dev/null +++ b/7p39.cpp @@ -0,0 +1,11 @@ + +/* + * + * 7.39 + * + * Not legal + */ + +int main () { + return 0; +} diff --git a/7p40.cpp b/7p40.cpp new file mode 100644 index 0000000..2161f0e --- /dev/null +++ b/7p40.cpp @@ -0,0 +1,40 @@ +#include <iostream> + +/* + * + * 7.40 + * + * + */ + +class Date { +public: + Date() { + epochtime = 11111111; // Just an example. This should "get" the current time. + } + Date(time_t i): epochtime(i) {} + std::ostream& printepoch(std::ostream& pecout) { + pecout << epochtime; + return pecout; + } + time_t getepoch() { return epochtime; } + std::string& getformatted() { + formatted = "TEST"; // Just an example, we format the time here. + return formatted; + } + +private: + time_t epochtime; + std::string formatted; +}; + +int main () { + + Date d1; + Date d2(342342423); + d1.printepoch(std::cout) << std::endl; + d2.printepoch(std::cout) << std::endl; + std::cout << d1.getepoch() << std::endl; + std::cout << d1.getformatted() << std::endl; + return 0; +} |