Chapter 10

An Object-oriented Approach

Postby Cuchulainn » Tue Apr 06, 2010 11:53 am

great, you're welcome.



BTW what version of Excel are you using?
User avatar
Cuchulainn
 
Posts: 676
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby steve » Tue Apr 06, 2010 4:35 pm

I am using Excel 2003. Thanks.



Cuchulainn wrote:great, you're welcome.



BTW what version of Excel are you using?
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby steve » Wed Apr 07, 2010 7:40 am

Chapter 10 code compiled successfully in VC++ but NOT in g++ Linux.

Errors seem indicate that g++ does not understand STL syntax. Could you please advice how to compile the code in g++ Linux?

Thank you!



g++ version

[root@localhost chap10]# g++ -v

Using built-in specs.

Target: i386-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux

Thread model: posix

gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)





Errors:

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:100: error: there are no arguments to ?Size? that depend on a template parameter, so

a declaration of ?Size? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:100: note: (if you use ?-fpermissive?, G++ will accept your code, but allowing the u

se of an undeclared name is deprecated)

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:100: error: there are no arguments to ?MinIndex? that depend on a template parameter

, so a declaration of ?MinIndex? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:103: error: there are no arguments to ?MinIndex? that depend on a template parameter

, so a declaration of ?MinIndex? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:103: error: there are no arguments to ?MaxIndex? that depend on a template parameter

, so a declaration of ?MaxIndex? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp: In member function ?Vector<V, I, S> Vector<V, I, S>::operator/(const V&) const?:

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:190: error: there are no arguments to ?Size? that depend on a template parameter, so

a declaration of ?Size? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:190: error: there are no arguments to ?MinIndex? that depend on a template parameter

, so a declaration of ?MinIndex? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:193: error: there are no arguments to ?MinIndex? that depend on a template parameter

, so a declaration of ?MinIndex? must be available

/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:193: error: there are no arguments to ?MaxIndex? that depend on a template parameter

, so a declaration of ?MaxIndex? must be available







Cuchulainn wrote:Well, strange,fdmdirector.cpp is on the official CD... Did you look in chapter 10 directory?



The error message means that the namespace is defined twice. Maybe it was my addition to the test program, so just remove it once. It means the same code is being inserted twice (chapter 2)



BTW, as a check how many files in total do you have on the CD?
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby Cuchulainn » Sun Apr 11, 2010 7:07 pm

The 2006 code was built using VS2005. For gcc, the compiler handles template classes differntly, especally friends



Vector<T>

{

template <T1>

void foo(T1& t);



//..

};



this must be done in gcc. VS has no problems with



Vector<T>

{

template <T>

void foo(T& t);



//..

};
User avatar
Cuchulainn
 
Posts: 676
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby steve » Mon Apr 12, 2010 9:23 am

It seems not work for me. I've changed as suggested. (original code and updated code below). But error is still same. it does not understand SIZE, MinIndex, MaxIndex:



/usr/data/CPP/CPP4FE/Utilities/VectorsAndMatrices/Vector.cpp:100: error: there are no arguments to ?SIZE? that depend on a template parameter, so a declaration of ?SIZE? must be available





--original:

template <class V, class I, class S>

Vector<V, I, S> Vector<V, I, S>::operator - () const

{ // Unary minus



// Create new vector of same size and same starting index

Vector<V, I, S> result(SIZE(), MinIndex());



// Copy all elements negative

for (I i=MinIndex(); i<=MaxIndex(); i++)

result[i] = - (*this)[i];



// Return result

return result;

}



--updated:

template <class V1, class I1, class S1>

Vector<V1, I1, S1> Vector<V1, I1, S1>::operator - () const

{ // Unary minus



// Create new vector of same size and same starting index

Vector<V1, I1, S1> result(SIZE(), MinIndex());



// Copy all elements negative

for (I1 i=MinIndex(); i<=MaxIndex(); i++)

result[i] = - (*this)[i];



// Return result

return result;

}



Cuchulainn wrote:The 2006 code was built using VS2005. For gcc, the compiler handles template classes differntly, especally friends



Vector<T>

{

template <T1>

void foo(T1& t);



//..

};



this must be done in gcc. VS has no problems with



Vector<T>

{

template <T>

void foo(T& t);



//..

};
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby Cuchulainn » Mon Apr 12, 2010 10:00 am

SIZE() ?? Don't know how you got this.

Size() is correct.
User avatar
Cuchulainn
 
Posts: 676
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby steve » Mon Apr 12, 2010 10:11 am

Yeah, sorry for confusion.

Original code is Size() but I failed with Size(), so just try the luck with SIZE() or size() but all failed.

Cuchulainn wrote:SIZE() ?? Don't know how you got this.

Size() is correct.
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby steve » Mon Apr 12, 2010 10:13 am

FYI: I've tried simple example with vector. below code works fine, g++ does understand size(), begin() ...,



#include <iostream>

#include <vector>

#include <string>



using namespace std;



main()

{

vector<string> SS;



SS.push_back("The number is 10");

SS.push_back("The number is 20");

SS.push_back("The number is 30");



cout << "Loop by index:" << endl;



int ii;

for(ii=0; ii < SS.size(); ii++)

{

cout << SS[ii] << endl;

}



cout << endl << "Constant Iterator:" << endl;



vector<string>::const_iterator cii;

for(cii=SS.begin(); cii!=SS.end(); cii++)

{

cout << *cii << endl;

}



cout << endl << "Reverse Iterator:" << endl;



vector<string>::reverse_iterator rii;

for(rii=SS.rbegin(); rii!=SS.rend(); ++rii)

{

cout << *rii << endl;

}



cout << endl << "Sample Output:" << endl;



cout << SS.size() << endl;

cout << SS[2] << endl;



swap(SS[0], SS[2]);

cout << SS[2] << endl;

}





Cuchulainn wrote:SIZE() ?? Don't know how you got this.

Size() is correct.
[/quote]
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Chapter 10

Postby R19et » Fri Dec 12, 2014 5:15 am

I too had this question and I thank you for your answer - I am trying to find a way to answer the first review question on chapter 414. Do you mean - how would we re-write rather than how would the the function be called?
User avatar
R19et
 
Posts: 5
Joined: Thu Dec 11, 2014 6:00 am

Re: Chapter 10

Postby VonMorgan » Wed Apr 10, 2019 11:31 am

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj
VonMorgan
 
Posts: 1
Joined: Mon Apr 08, 2019 12:25 pm

1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L

Postby R19et » Sat May 25, 2019 4:09 am

Image
Image
Image
Image
Image



Ford Mustang 2019 Blue 2.3L vin: 1FATP8UH3K5159596


Lot sold for 20900

Auction: I buy fast

Lot number: 28658375

Date of sale: 12.05.2019

Year: 2019

VIN: 1FATP8UH3K5159596

Condition: Run and Drive

Engine: 2.3L I4 N

Mileage: 827 miles (Actual)

Seller: Avis Budget Group

Documents: CLEAR (Florida)

Location: Orlando (FL)

Estimated Retail Value:

Transmission: Automatic

Body color: Blue

Drive: Rear Wheel Drive

Fuel: Gasoline

Keys: Present

Notes: Not specified





The Shelby GT350 is an incredibly fast car with an intoxicating engine
What’s new
Ford Mustang Shelby GT350 6
You may think of the Mustang as a drag-strip special, a muscle car built for straight lines and stoplight hauls. Ford, though, is serious about making the iconic pony car a significant performance machine both at the drag strip and on the race track.
We’ve long heard about the GT350 and its magnificent engine. After finally getting some seat time, it’s clear that the Shelby lives up to the hype. Sure, it’s effortlessly fast and a bargain, but the screaming motor and stellar exhaust note is what makes this one of the most special cars on sale.


1FATP8UH3K5159596


1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
User avatar
R19et
 
Posts: 5
Joined: Thu Dec 11, 2014 6:00 am

1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L

Postby R19et » Sat May 25, 2019 4:30 am

Image
Image
Image
Image
Image



Ford Mustang 2019 Blue 2.3L vin: 1FATP8UH3K5159596


Lot sold for 20900

Auction: I buy fast

Lot number: 28658375

Date of sale: 12.05.2019

Year: 2019

VIN: 1FATP8UH3K5159596

Condition: Run and Drive

Engine: 2.3L I4 N

Mileage: 827 miles (Actual)

Seller: Avis Budget Group

Documents: CLEAR (Florida)

Location: Orlando (FL)

Estimated Retail Value:

Transmission: Automatic

Body color: Blue

Drive: Rear Wheel Drive

Fuel: Gasoline

Keys: Present

Notes: Not specified





Source: Ford Motor Co.
Source: Ford Motor Co.
Source: Ford Motor Co.
Ford Mustang Shelby GT350 6
Also, we should note that Ford is coming out with a Shelby GT500 later this year. While it won’t have the crazy redline or insane sound of the flat-plane-crank V-8, it will make over 700 horsepower with the help of a supercharger. The GT350 may be best if you want a pure driver’s car, but the GT500 will officially be the top-dog Mustang when it hits showrooms.


1FATP8UH3K5159596


1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
1FATP8UH3K5159596 Ford Mustang 2019 Blue 2.3L
User avatar
R19et
 
Posts: 5
Joined: Thu Dec 11, 2014 6:00 am

Previous

Return to Introduction to C++ for Financial Engineers (Duffy)

Who is online

Users browsing this forum: No registered users and 1 guest

cron