I have written this code from a book i am reading but my complier warns be that symbol cout and endl could not be resolved. Why is that.
#include <iostream>
#include <float.h>
int main()
{
cout << "float: " << endl
<< "stevilo decimalnih mest: " << FLT_DIG << endl
<< "natancnost stevila....: " << FLT_EPSILON << endl
<< "Najmanjse stevilo.....: " << FLT_MIN << endl
<< "Najvecje stevilo......: " << FLT_MAX << endl
<< "Bitov v mantisi.......: " << FLT_MANT_DIG << endl
<< "Najvecji eksponent....: " << FLT_MAX_10_EXP << endl
<< "Najmlajsi eksponent...: " << FLT_MIN_10_EXP << endl;
return 0;
}
You would have to use namespace:
#include <iostream>
#include <float.h>
using namespace std;
or:
std::cout
You can read more about namespaces in c++ here
cout and endl are scoped. So you have to inform in which namespace there are.
Use
std::cout
std::endl
or badly add just after include
using namespace std;
Related
I want to output this face
all I see is question mark symbols
void win(){
cout << "░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "░░░░█▒▒▄▀▀▀▀▀▄▄▒▒▒▒▒▒▒▒▒▄▄▀▀▀▀▀▀▄" << endl;
cout << "░░▄▀▒▒▒▄█████▄▒█▒▒▒▒▒▒▒█▒▄█████▄▒█" << endl;
cout << "░█▒▒▒▒▐██▄████▌▒█▒▒▒▒▒█▒▐██▄████▌▒█" << endl;
cout << "▀▒▒▒▒▒▒▀█████▀▒▒█▒░▄▒▄█▒▒▀█████▀▒▒▒█" << endl;
cout << "▒▒▐▒▒▒░░░░▒▒▒▒▒█▒░▒▒▀▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "▒▌▒▒▒░░░▒▒▒▒▒▄▀▒░▒▄█▄█▄▒▀▄▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
cout << "▒▌▒▒▒▒░▒▒▒▒▒▒▀▄▒▒█▌▌▌▌▌█▄▀▒▒▒▒▒▒▒▒▒▒▒▐" << endl;
cout << "▒▐▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▀███▀▒▌▒▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
cout << "▀▀▄▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "▀▄▒▀▄▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▄▄▀" << endl;
cout << "▒▒▀▄▒▀▄▀▀▀▄▀▀▀▀▄▄▄▄▄▄▄▀░░░░▀▀▀▀▀▀" << endl;
}
If you are on Windows, the following code works as long as:
The console font supports the characters. I'm using Consolas font.
The source is compiled from source saved in an encoding that supports the characters. Saving as UTF-8 w/ BOM convinces many Windows applications that a file is UTF-8, but also check your compiler for source encoding options.
Note the use of wcout and wide strings (L"..."). Also, _setmode is used to alter stdout to support UTF-16 output.
#include <iostream>
#include <io.h>
#include <fcntl.h>
using namespace std;
void win(){
wcout << L"░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
wcout << L"░░░░█▒▒▄▀▀▀▀▀▄▄▒▒▒▒▒▒▒▒▒▄▄▀▀▀▀▀▀▄" << endl;
wcout << L"░░▄▀▒▒▒▄█████▄▒█▒▒▒▒▒▒▒█▒▄█████▄▒█" << endl;
wcout << L"░█▒▒▒▒▐██▄████▌▒█▒▒▒▒▒█▒▐██▄████▌▒█" << endl;
wcout << L"▀▒▒▒▒▒▒▀█████▀▒▒█▒░▄▒▄█▒▒▀█████▀▒▒▒█" << endl;
wcout << L"▒▒▐▒▒▒░░░░▒▒▒▒▒█▒░▒▒▀▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
wcout << L"▒▌▒▒▒░░░▒▒▒▒▒▄▀▒░▒▄█▄█▄▒▀▄▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
wcout << L"▒▌▒▒▒▒░▒▒▒▒▒▒▀▄▒▒█▌▌▌▌▌█▄▀▒▒▒▒▒▒▒▒▒▒▒▐" << endl;
wcout << L"▒▐▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▀███▀▒▌▒▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
wcout << L"▀▀▄▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▒▒█" << endl;
wcout << L"▀▄▒▀▄▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▄▄▀" << endl;
wcout << L"▒▒▀▄▒▀▄▀▀▀▄▀▀▀▀▄▄▄▄▄▄▄▀░░░░▀▀▀▀▀▀" << endl;
}
int main(){
_setmode(_fileno(stdout), _O_U16TEXT);
win();
return 0;
}
Output:
Are you using windows or an unix based system (macos/linux), because windows does not use utf8 by default like macos and linux.
On macos (which i am using) your code compiles an runs completely fine:
#include <iostream>
using namespace std;
void win(){
cout << "░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "░░░░█▒▒▄▀▀▀▀▀▄▄▒▒▒▒▒▒▒▒▒▄▄▀▀▀▀▀▀▄" << endl;
cout << "░░▄▀▒▒▒▄█████▄▒█▒▒▒▒▒▒▒█▒▄█████▄▒█" << endl;
cout << "░█▒▒▒▒▐██▄████▌▒█▒▒▒▒▒█▒▐██▄████▌▒█" << endl;
cout << "▀▒▒▒▒▒▒▀█████▀▒▒█▒░▄▒▄█▒▒▀█████▀▒▒▒█" << endl;
cout << "▒▒▐▒▒▒░░░░▒▒▒▒▒█▒░▒▒▀▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "▒▌▒▒▒░░░▒▒▒▒▒▄▀▒░▒▄█▄█▄▒▀▄▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
cout << "▒▌▒▒▒▒░▒▒▒▒▒▒▀▄▒▒█▌▌▌▌▌█▄▀▒▒▒▒▒▒▒▒▒▒▒▐" << endl;
cout << "▒▐▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▀███▀▒▌▒▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
cout << "▀▀▄▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▒▒█" << endl;
cout << "▀▄▒▀▄▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▄▄▀" << endl;
cout << "▒▒▀▄▒▀▄▀▀▀▄▀▀▀▀▄▄▄▄▄▄▄▀░░░░▀▀▀▀▀▀" << endl;
}
int main(){
win();
return 0;
}
and gives the desired output:
░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█
░░░░█▒▒▄▀▀▀▀▀▄▄▒▒▒▒▒▒▒▒▒▄▄▀▀▀▀▀▀▄
░░▄▀▒▒▒▄█████▄▒█▒▒▒▒▒▒▒█▒▄█████▄▒█
░█▒▒▒▒▐██▄████▌▒█▒▒▒▒▒█▒▐██▄████▌▒█
▀▒▒▒▒▒▒▀█████▀▒▒█▒░▄▒▄█▒▒▀█████▀▒▒▒█
▒▒▐▒▒▒░░░░▒▒▒▒▒█▒░▒▒▀▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█
▒▌▒▒▒░░░▒▒▒▒▒▄▀▒░▒▄█▄█▄▒▀▄▒▒▒▒▒▒▒▒▒▒▒▌
▒▌▒▒▒▒░▒▒▒▒▒▒▀▄▒▒█▌▌▌▌▌█▄▀▒▒▒▒▒▒▒▒▒▒▒▐
▒▐▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▀███▀▒▌▒▒▒▒▒▒▒▒▒▒▒▒▌
▀▀▄▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▒▒█
▀▄▒▀▄▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▄▄▀
▒▒▀▄▒▀▄▀▀▀▄▀▀▀▀▄▄▄▄▄▄▄▀░░░░▀▀▀▀▀▀
but on windows it prints:
????????????????????????????
???????????????????????????????
??????????????????????????????????
????????????????????????????????????
and so on.
So i think the problem lies in the fact the machine/terminal you are using does not support unicode.
A solution could be to use std::wcout which is for "wide" characters an example could be this:
std::wcout << L"█" << std::endl;
Or using utf16:
#include <iostream>
using std::cout;
using std::endl;
void win(){
cout << "\u2591\u2591\u2591\u2591\u2588\u2592\u2592\u2592\u2592\u2591\u2591\u2591\u2591\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2588" << endl;
cout << "\u2591\u2591\u2591\u2591\u2588\u2592\u2592\u2584\u2580\u2580\u2580\u2580\u2580\u2584\u2584\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2584\u2584\u2580\u2580\u2580\u2580\u2580\u2580\u2584" << endl;
cout << "\u2591\u2591\u2584\u2580\u2592\u2592\u2592\u2584\u2588\u2588\u2588\u2588\u2588\u2584\u2592\u2588\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2588\u2592\u2584\u2588\u2588\u2588\u2588\u2588\u2584\u2592\u2588" << endl;
cout << "\u2591\u2588\u2592\u2592\u2592\u2592\u2590\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u258C\u2592\u2588\u2592\u2592\u2592\u2592\u2592\u2588\u2592\u2590\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u258C\u2592\u2588" << endl;
cout << "\u2580\u2592\u2592\u2592\u2592\u2592\u2592\u2580\u2588\u2588\u2588\u2588\u2588\u2580\u2592\u2592\u2588\u2592\u2591\u2584\u2592\u2584\u2588\u2592\u2592\u2580\u2588\u2588\u2588\u2588\u2588\u2580\u2592\u2592\u2592\u2588" << endl;
cout << "\u2592\u2592\u2590\u2592\u2592\u2592\u2591\u2591\u2591\u2591\u2592\u2592\u2592\u2592\u2592\u2588\u2592\u2591\u2592\u2592\u2580\u2592\u2592\u2588\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2588" << endl;
cout << "\u2592\u258C\u2592\u2592\u2592\u2591\u2591\u2591\u2592\u2592\u2592\u2592\u2592\u2584\u2580\u2592\u2591\u2592\u2584\u2588\u2584\u2588\u2584\u2592\u2580\u2584\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u258C" << endl;
cout << "\u2592\u258C\u2592\u2592\u2592\u2592\u2591\u2592\u2592\u2592\u2592\u2592\u2592\u2580\u2584\u2592\u2592\u2588\u258C\u258C\u258C\u258C\u258C\u2588\u2584\u2580\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2590" << endl;
cout << "\u2592\u2590\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u258C\u2592\u2592\u2580\u2588\u2588\u2588\u2580\u2592\u258C\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u258C" << endl;
cout << "\u2580\u2580\u2584\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u258C\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2590\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2588" << endl;
cout << "\u2580\u2584\u2592\u2580\u2584\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2590\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2584\u2584\u2584\u2584\u2592\u2592\u2592\u2592\u2592\u2592\u2584\u2584\u2580" << endl;
cout << "\u2592\u2592\u2580\u2584\u2592\u2580\u2584\u2580\u2580\u2580\u2584\u2580\u2580\u2580\u2580\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2580\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580" << endl;
}
int main(){
win();
}
But again if your terminal does not support Unicode there is No way to print it.
I have compilation errors to just simply output a cout message. Below is my code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
char letter = 'a';
short age = 10;
int cout = 575;
long numStars = 985632145;
float pi = 3.1;
double price = 89.65;
string season = "summer";
cout << "Letter: "<< letter << endl;
std::cout << "Age: " << age<< endl;
std::cout << "Cout: " << cout << endl;
std::cout << "Number Stars: " << numStars << endl;
std::cout << "Pi: " << pi << endl;
std::cout << "Price: " << price << endl;
std::cout << "Season: " << season;
system("pause");
return 0;
}
The errors I get are on the line:
cout << "Letter: "<< letter << endl;
I have tried reinstalling VS2015 but that didn't help.
You have a variable of type int called cout - this is not allowed given that you are using namespace std. Change this variable name to something else, and avoid the statement using namespace std.
std::cout is a "reserved type/keyword" so you cannot use it as a variable name.
finishing up a long project and the final step is to make sure my data lines up in the proper column. easy. Only I am having trouble with this and have been at it for longer than i wish to admit watching many videos and can't really grasp what the heck to do So here is a little snippet of the code that I'm having trouble with:
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
cout << "Student Grade Summary\n";
cout << "---------------------\n\n";
cout << "BIOLOGY CLASS\n\n";
cout << "Student Final Final Letter\n";
cout << "Name Exam Avg Grade\n";
cout << "----------------------------------------------------------------\n";
cout << "bill"<< " " << "joeyyyyyyy" << right << setw(23)
<< "89" << " " << "21.00" << " "
<< "43" << "\n";
cout << "Bob James" << right << setw(23)
<< "89" << " " << "21.00" << " "
<< "43" << "\n";
}
which works for the first entry but the bob james entry has the numbers all askew. I thought setw was supposed to allow you to ignore that? What am i missing?
Thanks
It doesn't work as you think. std::setw sets the width of the field only for the next insertion (i.e., it is not "sticky").
Try something like this instead:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout << "Student Grade Summary\n";
cout << "---------------------\n\n";
cout << "BIOLOGY CLASS\n\n";
cout << left << setw(42) << "Student" // left is a sticky manipulator
<< setw(8) << "Final" << setw(6) << "Final"
<< "Letter" << "\n";
cout << setw(42) << "Name"
<< setw(8) << "Exam" << setw(6) << "Avg"
<< "Grade" << "\n";
cout << setw(62) << setfill('-') << "";
cout << setfill(' ') << "\n";
cout << setw(42) << "bill joeyyyyyyy"
<< setw(8) << "89" << setw(6) << "21.00"
<< "43" << "\n";
cout << setw(42) << "Bob James"
<< setw(8) << "89" << setw(6) << "21.00"
<< "43" << "\n";
}
Also related: What's the deal with setw()?
The manipulators << right << setw(23) are telling the ostream that you want
the string "89" set in the right-hand edge of a 23-character-wide field.
There is nothing to tell the ostream where you want that field to start,
however, except for the width of the strings that are output since the
last newline.
And << "bill"<< " " << "joeyyyyyyy" writes a lot more characters to the output
than << "Bob James" does, so the 23-character-wide field on the second line
starts quite a bit to the left of the same field on the first line.
Stream manipulators affect the next input/output value being streamed, and then some manipulators (including setw()) reset afterwards. So you need to set the width and alignment BEFORE you output a text string, not afterwards.
Try something more like this:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void outputStudent(const string &firstName, const string &lastName,
int finalExam, float finalAvg, int letterGrade)
{
cout << setw(40) << left << (firstName + " " + lastName) << " "
<< setw(6) << right << finalExam << " "
<< setw(6) << right << fixed << setprecision(2) << finalAvg << " "
<< setw(7) << right << letterGrade << "\n";
}
int main()
{
cout << "Student Grade Summary\n";
cout << "---------------------\n\n";
cout << "BIOLOGY CLASS\n\n";
cout << "Student Final Final Letter\n";
cout << "Name Exam Avg Grade\n";
cout << "--------------------------------------------------------------\n";
outputStudent("bill", "joeyyyyyyy", 89, 21.00, 43);
outputStudent("Bob", "James", 89, 21.00, 43);
cin.get();
return 0;
}
Output:
Student Grade Summary
---------------------
BIOLOGY CLASS
Student Final Final Letter
Name Exam Avg Grade
--------------------------------------------------------------
bill joeyyyyyyy 89 21.00 43
Bob James 89 21.00 43
I'm trying to include experiencecalculator from a class but I get this Error: a nonstatic member reference must be relative to a specific object.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <windows.h>
#include "ExpCalc.h"
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
int main() {
cout << "Pick which calculator you would like to use by typing the correct "
"number.\n";
cout << "1. Experience Calculator" << endl;
// cout << "" Insert other calculators and there number here.
// cout << ""
int choice;
cin >> choice;
if (choice == 1) {
ExpCalc::ExperienceCalculator;
}
}
The class I am taking it from is:
ExpCalc.h
class ExpCalc
{
public:
ExpCalc();
int ExperienceCalculator;
};
ExpCalc.cpp
#include "stdafx.h"
#include "ExpCalc.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <windows.h>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
ExpCalc::ExpCalc() {}
int ExperienceCalculator() {
double timetotal;
double timeperinv;
double xptotal;
double xpitem;
double amount;
double perinv;
double totalinv;
double costper;
double costtotal;
SetConsoleTitle(TEXT("Runescape Skill Calculator"));
cout << "=+=+=+=+=+=+=+=+=+=+=+=+=+=Runescape Skill "
"Calculator=+=+=+=+=+=+=+=+=+=+=+=+=+=" << endl;
cout << endl;
cout << "How much experience do you want to get?" << endl;
cin >> xptotal;
cout << endl;
cout << "How much does it cost per item?" << endl;
cin >> costper;
cout << endl;
cout << "How much experience do you get per item?" << endl;
cin >> xpitem;
cout << endl;
cout << "How many items can you process in one inventory?" << endl;
cin >> perinv;
cout << endl;
cout << "How long does it take to process one inventory of items?" << endl;
cin >> timeperinv;
system("CLS");
amount = xptotal / xpitem;
totalinv = amount / perinv;
timetotal = totalinv * timeperinv;
costtotal = amount * costper;
cout << "=+=+=+=+=+=+=+=+=+=+=+=+=+=Runescape Skill "
"Calculator=+=+=+=+=+=+=+=+=+=+=+=+=+=" << endl;
cout << endl;
std::cout << std::setprecision(1) << fixed;
cout << "The amount of items that you will need to process is: \n" << amount
<< endl;
cout << endl;
cout << "The total amount of inventories to process all items is: \n"
<< totalinv << endl;
cout << endl;
cout << "The total time it will take to complete processing all items is:\n"
<< timetotal << endl;
cout << endl;
cout << "The total cost of the items will be: \n" << totalinv << endl;
cout << endl;
cout << "The total amount of inventories to process is: \n" << totalinv
<< endl;
cout << endl;
cout << "=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+==+=+==+=+==+=+==+=+==+=+=+=+=+=+=+="
"+=+=+=+=+=+=+=" << endl;
system("PAUSE");
return 0;
};
Any help will be much appreciated!
Your H file describes ExperienceCalculator as int field. Your CPP file describes ExperienceCalculator as a free function (even not a method of ExpCalc). So I suspect that you have to do the following amends:
H file:
int ExperienceCalculator(); // parenthesis to be added
CPP file:
int ExpCalc::ExperienceCalculator() { // class name ExpCalc to be added
main file:
if (choice == 1) {
ExpCalc exp_calc; // instantiate the class
exp_calc.ExperienceCalculator(); // make a call to non-static method
}
Alternatively, you can make the method as static but let make one step at a time. Happy coding!
I've been trying a program from codeproject, about ptr_vector, and while compiling, the above error is shown.
Googling shows no hope to solve this problem. Could anyone here help out?
Here's the entire code (am compiling with gcc 4.2.2)
#include <iostream>
#include <string>
#include <boost/ptr_container/ptr_vector.hpp>
using namespace std; // for cout, endl, find, replace, ...
using namespace stdx; // for ptr_vector, ptr_vector_owner
using namespace boost;
int main()
{
cout << "---- ptr_vector demo ----" << endl;
ptr_vector<string> ptv;
ptr_vector_owner<string> owner (ptv); // scope-guard: owner of new-ed objects
ptv.push_back (new string ("Peter"));
ptv.push_back (new string ("Paul"));
ptv.insert (ptv.end(), new string ("Margaret"));
cout << " 1: " << ptv.front() << " " << ptv.back() << endl;
cout << " 2: " << ptv[1] << " " << ptv.at(2) << endl;
cout << " 3: " << *ptv.begin() << " " << *(ptv.begin() + 1) << endl;
cout << " 4:";
for (ptr_vector<string>::iterator it = ptv.begin(); it != ptv.end(); ++it)
cout << " " << *it;
cout << endl;
ptv.sort();
cout << " 5: " << ptv[0] << " " << ptv[1] << " " << ptv[2] << endl;
ptv.sort (greater<string>());
cout << " 6: " << ptv[0] << " " << ptv[1] << " " << ptv[2] << endl;
ptr_vector<string>::iterator iter;
iter = find (ptv.begin(), ptv.end(), "Paul");
if (iter != ptv.end())
cout << " 7: " << *iter << endl;
replace (ptv.begin(), ptv.end(), string ("Paul"), string ("Fred"));
cout << " 8: " << ptv.begin()[1] << endl;
string* str = ptv.pop_back();
cout << " 9: " << *str << " - size: " << ptv.size() << endl;
delete str;
delete ptv.detach (ptv.begin());
cout << "10: " << ptv[0] << " - size: " << ptv.size() << endl;
ptr_vector<string> ptvTwo;
ptr_vector_owner<string> ownerTwo (ptvTwo);
ptvTwo.push_back (new string ("Elisabeth"));
ptvTwo.push_back (new string ("Susan"));
ptv.swap(ptvTwo);
if (ptv < ptvTwo)
cout << "11: " << *ptv.begin() << " - size: " << ptv.size() << endl;
return 0;
}//main
stdx is not a standard namespace, it is defined by the particular implementation you are trying to use. You are not using the header file include #include "ptr_vector.h" inside which namespace stdx exists. Currently the ptr_vector you are using is being included from boost namespce. That begs the question, if you can use boost why do you want use stdx namespace solution.