Member Avatar

//Hi all,could someone explain the make_shared(), is it used to substitute constructor? //Here is an example void DoAddStaff(vector<Ptr>& container) { cout << "\nEnter type of employee to add ('W' for waged, 'S' for salaried): "; char c; cin >> c; cin.ignore(); if( c == 'w' || c == 'W' ) { cout << "\nEnter waged employee's name: "; string name; getline(cin, name); cout << "\nEnter waged employee's hourly rate of pay: "; double rate; cin >> rate; cin.ignore(); container.push_back( make_shared<CWagedEmployee>(name, CreateEmplNum( container ), rate) ); } else if( c == 's' || c == 'S' ) { cout << "\nEnter …

Member Avatar
0
16
Member Avatar

//This is my code,how do i find & print max value namespace StartCSharp { class Program { static void Main(string[] args) { int [, ] a = new int [4,4] {{2,3,4,5}, {34,56,25,67}, {22,44,55,77},{45,80,22,13}}; foreach (int x in a) Console.WriteLine(x); } } } ///Thank you.

Member Avatar
0
24
Member Avatar

//HI All what is wrong with this code,i try to declare 4 dim. array int [, , ,] a = new int [3,4] = {{2,3,4,5}, {34,56,25,67}, {22,44,55,77}}; //how do i declare it an assign values to it?Thanks.

Member Avatar
0
18
Member Avatar

//Hi i do the delivery company project,this are my members of the base class //how do i create 2 constructors in base,one for sender and one for recipient? //I did one for sender ,but visual studio does not allow me to create identical for recipient //Can some one help to figure it out,please? #pragma once #include<string> using namespace std; class Package { public: Package(); ~Package(); protected: string senderName; string senderAddress; string senderCity; string senderState; string senderZipCode; string recipientName; string recipientAddress; string recipientCity; string recipientState; string recipientZipCode; double weight; double ShippingCost; public: virtual void CalculateCost(void) = 0; virtual void Display(void) = …

Member Avatar
0
72
Member Avatar

//Hi all,can someone help with this problem //I am stack,need to output all functions in main,with user input for queue and stack,but first queue //This is my .h and .cpp of queue #include "stdafx.h" template <class ItemType> struct NodeType; template <class ItemType> class QueType { public: QueType(); // Class constructor. ~QueType(); // Class destructor. void MakeEmpty(); bool IsEmpty() const; bool IsFull() const; void Enqueue(ItemType newItem); void Dequeue(ItemType& item); void PrintQue(); private: NodeType<ItemType>* qFront; NodeType<ItemType>* qRear; }; //template <class ItemType> //struct NodeType //{ // ItemType info; // NodeType* next; //}; template <class ItemType> QueType<ItemType>::QueType() // Class constructor. // Post: qFront and …

Member Avatar
0
18
Member Avatar

//Hi all,can you please explain why using this-> in this code is optional,that is the purpose? //Code can work with not this-> too. CTime_24 operator+(int seconds); CTime_24 CTime_24 :: operator+(int seconds) { CTime_24 temp; temp.m_Seconds = this->m_Seconds + seconds; temp.m_Minutes = this->m_Minutes + temp.m_Seconds / 60; temp.m_Seconds %= 60; temp.m_Hours = this -> m_Hours + temp.m_Minutes / 60; temp.m_Minutes %= 60; temp.m_Hours %= 24; return temp; } int main() { CTime_24 time2(6, 20, 59); time2.GetTime(hour, minute, second); cout << "time2=" << hour << " : " << minute << " : " << second << endl; ////OVERLOADED OPERATOR CALL/////// time2 …

Member Avatar
0
32
Member Avatar

//why the getters declared twice,public,and than protected at the end of this code? And how to assign the copy constructor between this 2 classes? class Person { private: string name; string address; string city; string state; string zipCode; public: Person() {} Person(const string& aName, const string& anAddress, const string& aCity, const string& aState, const string& aZipCode) : name(aName), address(anAddress), city(aCity), state(aState), zipCode(aZipCode) {} ~Person() {} // Getters const string& getName() const { return name; } const string& getAddress() const { return address; } const string& getCity() const { return city; } const string& getState() const { return state; } const …

Member Avatar
0
14
Member Avatar

//Hi,i need to create programm,which takes the user input,determins how many digits in integer // and than raise this digit to power,what was entered by user too. //first function noraml,second one to rais to power recursive. So if user enter number //234,this is 3 digits,so now need recurcively 3 raise to the power . // This what i got so far program determins the digits from integer,but does not use power // Power of size number.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<string> using namespace std; typedef long double ld; int countDigits(int number) { …

Member Avatar
0
49
Member Avatar

//Hi all,can you explain how to call this function in main. //i ask user to enter the number,like this is it correct in main,recursevely call function? bool isPrime(int n, int d); int main() { int number; cout <<"Enter number >= 1"; cin >> number; if(isPrime(number)) { return cout << "Yes"; else return cout << "No"; } return 0; } bool isPrime(int n, int d) { if(n<2) return 0; if(d == 1) return true; else { if(n % d == 0) return false; else return isPrime(n, d - 1); } }

Member Avatar
0
20
Member Avatar

//Hi,can someone explain the meaning of [size -2],why not [size -1],if we narrowing the string int palindrome(char str[], int size); int main() { cout << "Enter a string: "; char str[20]; cin.getline(str,20,'\n'); cout << "The entered string " << ( (palindrome(str,strlen(str)+1))? "is":"is not" ) << " a Palindrome string." << endl; return 0; } int palindrome(char str[], int size) { if (str[0] != str[size-2]) //if first element is not equal to last element. return 0; else if (strlen(str) <= 1) return 1; else return palindrome(str+1,size-2); }

Member Avatar
0
26
Member Avatar

int Cabin (int n); int _tmain(int argc, _TCHAR* argv[]) { cout << Cabin(8) << endl; return 0; } int Cabin (int n) { if (n == 1) return 0; else return Cabin(n/2) + 1; } Hi ,can someone explain why is the answer 3 here:if to folow the formula the answer is 8,5,3,2,1 and then if to return values,can not be 3,were is my mistake in logic?

Member Avatar
0
20
Member Avatar

//Hi Lads.This is my first attempt to create template functions. //Here is the main ,which needed to create Locate.h file/header and //in that Locate.h create templates to support the main. //If the value does not exist in the array, -1 is returned. // Templates.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Locate.h" using namespace std; typedef int ItemType; int _tmain(int argc, _TCHAR* argv[]) { const int arraySize = 10; ItemType array1[arraySize] = { 23, 43, 12, 45, 65, 77, 22, 10, 99, 43 }; cout << "The values in the array as are follows: …

Member Avatar
0
33
Member Avatar

//Hi all ,can you explain why does this functon has two returns? //How to read them? Is it like if/else? int _tmain(int argc, _TCHAR* argv[]) { int x, n; int res; int power(int, int); cout << "Enter a number:"; cin >> x; cout << "Enter a power:"; cin >> n; res = power(x, n); cout << "X^N is:" << res << endl; return 0; } int power(int x, int n) { if (n == 0) return 1; if (n % 2 == 0) return power(x*x, n / 2); return power(x*x, n / 2)*x; }

Member Avatar
0
32
Member Avatar

Hi all,have this code: Hi all,have this code: How do i implement binary search to display item.. found at index.. #include "stdafx.h" #include<fstream> #include<iostream> #include<string> #include<iomanip> using namespace std; struct sDetails{ int kNum; string Name; }; int _tmain(int argc, _TCHAR* argv[]) { sDetails students[5]; ifstream infile; infile.open("student.txt"); for (int i = 0; i < 5; i++) { infile >> students[i].kNum >> students[i].Name; } cout << "The Class List Is:\n"; cout << "KNUM\t\tNAME\n"; cout << endl; for (int i = 0; i < 5; i++) { cout << students[i].kNum << setw(15) << right << students[i].Name << endl; } infile.close(); return 0; …

Member Avatar
0
24
Member Avatar

Hi,i used this example for practicing,supposed to be easy one,but,abit confusing. Can you help to solve and point to mistakes i've done. Postman Pat became bored one night at the postal sorting office and to break the monotony of the nightshift, he carried out the following experiment with a row of mailboxes (all initially closed) in the post office. These mailboxes are numbered 1 through to 150, and beginning with mailbox 2, he opened the doors of all the even-numbered mailboxes. Next, beginning with mailbox 3, he went to every third mailbox, opening its door if it was closed and …

Member Avatar
0
64
Member Avatar

Comuter reboots itself 2-3 times each time at start up(at booting time) ,after giving a blue screen. Checked the error with blue screen viewer and it says problem with Hardware abstract layer,none page fault in none page area. Really annoing ,each time i start,need to wait this circle to pass.Any ides?Thanks

Member Avatar
0
10
Member Avatar

Hi,i used this example for practicing,supposed to be easy one,but,abit confusing. Can you help to solve and point to mistakes i've done. Postman Pat became bored one night at the postal sorting office and to break the monotony of the nightshift, he carried out the following experiment with a row of mailboxes (all initially closed) in the post office. These mailboxes are numbered 1 through to 150, and beginning with mailbox 2, he opened the doors of all the even-numbered mailboxes. Next, beginning with mailbox 3, he went to every third mailbox, opening its door if it was closed and …

Member Avatar
0
21
Member Avatar

//HI,need help to extract info from text file and display. //Here is my text file called Report.txt 01 09 2014 john 3.4 12.5 9.5 02 09 2014 freddy 3.4 12.5 9.5 03 09 2014 conor 3.4 12.5 9.5 04 09 2014 mike 3.4 12.5 9.5 05 09 2014 john 3.4 12.5 9.5 06 09 2014 john 3.4 12.5 9.5 07 09 2014 mike 3.4 12.5 9.5 08 09 2014 freddy 3.4 12.5 9.5 09 09 2014 conor 3.4 12.5 9.5 10 09 2014 conor 3.4 12.5 9.5 11 09 2014 john 3.4 12.5 9.5 12 09 2014 mike 3.4 12.5 …

Member Avatar
0
71
Member Avatar

#include "stdafx.h" #include<iostream> #include<fstream> #include<string> #include<vector> using namespace std; struct DATE{ int day; int month; int year; }; struct onDutyRecords{ string name; double sunshine; double rainfall; double midTemp; DATE date; }; onDutyRecords person; int ShowMenu(void); void ListDaysOnDutyOfMet(vector <onDutyRecords> &); void ListAllTheWetDays(vector <onDutyRecords> &); void ListDaysOnDutyOfMet(vector <onDutyRecords> &); void ListAllTheSunnyDays(vector <onDutyRecords> &); void ListAverageOfTwoDays(vector <onDutyRecords> &); void ListHotestDayByMiddayTemp(vector <onDutyRecords> &); void ListDaysWithShortestSunshine(vector <onDutyRecords> &); void Exit(void); bool quitFlag = false; int _tmain(int argc, _TCHAR* argv[]) { vector <onDutyRecords> records; ifstream infile("Report.txt"); //what next on this line to extract file into vector? // so i could create functions below //what is wrong …

Member Avatar
0
29
Member Avatar

Hi everyone. I have a bit confusion about vector. here is my 2 structs <global>and in the main have vector declared. file name is"report.txt" Have file with meteo readings,like • the meteorologist’s name on duty that day (a string of up to 12 characters) • hours of sunshine (double) • rainfall in millimeters (double) • midday temperature in degrees (double) looks like 12 1 2009 tommy 3.4 12.5 9.5 ...... so on for a full month. The question is how do i copy file contents into vector for a use. Here what i have : struct DATE{ int day; int …

Member Avatar
0
18
Member Avatar

Hi can any one tell me please does visual studio 2012 support any features of c++11? Or only in 2013 version?

Member Avatar
0
15
Member Avatar

class Animal { string _name; string _type; string _sound; // private constructor prevents construction of base class Animal(){}; protected: // protected constructor for use by derived classes Animal(const string & n, const string & t, const string & s) : _name(n), _type(t), _sound(s) {} public: void speak() const; const string & name() const { return _name; } const string & type() const { return _type; } const string & sound() const { return _sound; } }; void Animal::speak() const { printf("%s the %s says %s\n", _name.c_str(), _type.c_str(), _sound.c_str()); } // Dog class - derived from Animal class Dog : public …

Member Avatar
0
32
Member Avatar

Hi,can you explain the use of **for_each and lambda** in c++11.What are they for,how to use? I have seen a few examples but do not get the meaning.Thank you.

Member Avatar
0
21
Member Avatar

Hi i started the book c++ from ground up,but looks like it's too old.I came across the bonded array.Question- what are they,where to use them,how and are they still used in c++11? Thank you .

Member Avatar
0
36
Member Avatar

The containers SET/VECTOR/LIST/MAP are very similar in use,so how to choose which one to use? Is where any special cases? Thanks

Member Avatar
0
30
Member Avatar

//Hi,can someone explain what is the difference of declaring the main in C++/C++11 //What is most common may to use or it's metter of personal choice? int main() { return 0; } /////////////////// int _tmain(int argc, _TCHAR* argv[]) { return 0; } /////////////////// int main( int argc, char ** argv ) { return 0; }

Member Avatar
0
22
Member Avatar

#include<utility> #include<tuple> #include "stdafx.h" #include<string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { pair<int, string>p(42, "forty-two"); cout << p.first << " " << p.second << endl; p = make_pair<int,string>(112,"one-one-two") ; cout << p.first << " " << p.second << endl; return 0; } // Can some one help to figure out,i use visual studio 2013 and here on line 14 //i get an error -no instance of function template.It's something to do with make_pair.Thanks

Member Avatar
0
16
Member Avatar

#include "stdafx.h" #include<vector> #include<iostream> using namespace std; int main( int argc, char ** argv ) { // from initializer list (C++11) cout << "vector from initializer list (C++11): " << endl; vector<int> vi1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; cout << "size: " << vi1.size() << endl; cout << "front: " << vi1.front() << endl; cout << "back: " << vi1.back() << endl; cout << "insert 42 at begin + 5: " << endl; vi1.insert(vi1.begin() + 5, 42); cout << "size: " << vi1.size() << endl; cout << "vi1[5]: " << vi1[5] << …

Member Avatar
0
25

The End.