|
ex1-2.cpp - Example 1-2 Namespace std and new Header filenames |
// File: ex1-2.cpp - namespace std and the new header filenames
namespace mystuff
{
int cout = 5;
double sqrt(double x)
{
return x / 2.0;
}
};
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
using namespace std;
int main(void)
{
// char cout[32] = "This is a bad idea";
char temp[80];
cout << "hey\n";
std::cout << "the square root of 2 is " << sqrt(2.) << endl;
strcpy(temp,"hello");
strcat(temp," there");
std::cout << strlen(temp) << temp << endl;
std::cout << atoi("4") << endl;
std::cout << toupper('a') << endl;
std::cout << (char)toupper('a') << endl;
std::cout << mystuff::cout << ' ' << endl;
std::cout << sqrt(5.75) << ' ' << mystuff::sqrt(5.75) << endl;
return 0;
}
CIS27: Programming in C++ Instructor: Joe Bentley