1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex4.3/main.cpp
2019-12-17 15:05:27 +01:00

35 lines
1.1 KiB
C++

#include <iostream>
#include <cstring>
#include "String.hh"
int main() {
String str("Blubaloo");
std::cout << "String '" << str.data() << "' is " << str.length() << " chars long." << std::endl;
// Chain Assignment
std::cout << "String assignment" << std::endl;
String a, b;
a = b = String("Empty");
std::cout << "String '" << a.data() << "' is " << a.length() << " chars long." << std::endl;
std::cout << "String '" << b.data() << "' is " << b.length() << " chars long." << std::endl;
// Operator+
std::cout << "Operator +" << std::endl;
a = String("Loose") + String(" Statement");
std::cout << "String '" << a.data() << "' is " << a.length() << " chars long." << std::endl;
// Operator+=
std::cout << "Operator +=" << std::endl;
b += " " ; // String takes a const char* as input to constructor, so autoconversion available
b += a ;
std::cout << "String '" << b.data() << "' is " << b.length() << " chars long." << std::endl;
// Type Conversion
std::cout << "Type Conversion" << std::endl;
String c("Almost Empty");
std::cout << "String '" << c.data() << "' is " << strlen(c) << " chars long." << std::endl;
}