473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How Hazardous is the following code

Hi Folks,

still on the linked list problem...

how hazardous is the following code...i realize i do not have
copy/assignment defined and there is no exception handling...but was
wondering about the stl::list constructor and destructor.

i cannot inherit stl::list's ctor or dto - i think. Do not know how to
properly create/breakdown base class

any help greatly appreciated

Barry

// safeList.h

#ifndef SAFELIST_H
#define SAFELIST_H

using namespace std;
#include <list>
#include <iterator>
#include <memory>
#include <stdexcept>

//typedef list<T> S;
//typedef list<T>::iterator SI;

template<typename T>
class SafeList : private list<T> {
public:
SafeList() : list<T>() {}//No no-arg ctor not sure if i correctly
created an stl::list?
using list<T>::push_front;
using list<T>::size;
virtual ~SafeList() {}
private:
// SafeList(const SafeList&);
// SafeList& operator = (const SafeList&);
};
#endif

#include <iostream>
#include "safeList.h"

using namespace std;

int main()
{
SafeList<int> SL;
SL.push_front(10);
SL.push_front(20);
SL.push_front(30);
SL.push_front(40);
cout << "The size of the list is: " << SL.size() << endl;
//i think i should call ~stl::list<T>...not sure

}
Jul 23 '05 #1
2 1117

"Barry Hynes" <hy****@mar.dfo-mpo.gc.ca> skrev i en meddelelse
news:zk*******************@ursa-nb00s0.nbnet.nb.ca...
Hi Folks,

still on the linked list problem...

how hazardous is the following code...i realize i do not have
copy/assignment defined and there is no exception handling...but was
wondering about the stl::list constructor and destructor.

i cannot inherit stl::list's ctor or dto - i think. Do not know how to
properly create/breakdown base class

any help greatly appreciated

Barry

// safeList.h

#ifndef SAFELIST_H
#define SAFELIST_H

using namespace std;
#include <list>
#include <iterator>
#include <memory>
#include <stdexcept>

//typedef list<T> S;
//typedef list<T>::iterator SI;

template<typename T>
class SafeList : private list<T> {
public:
SafeList() : list<T>() {}//No no-arg ctor not sure if i correctly
created an stl::list?
using list<T>::push_front;
using list<T>::size;
virtual ~SafeList() {}
No reason for a virtual destructor here. SafeList is NOT a list.
private:
// SafeList(const SafeList&);
// SafeList& operator = (const SafeList&);
};
#endif

#include <iostream>
#include "safeList.h"

using namespace std;

int main()
{
SafeList<int> SL;
SL.push_front(10);
SL.push_front(20);
SL.push_front(30);
SL.push_front(40);
cout << "The size of the list is: " << SL.size() << endl;
//i think i should call ~stl::list<T>...not sure

}

I see no problem but also I do not see what you solve. A list with only some
of the "goodies" available?

/Peter
Jul 23 '05 #2

"Peter Koch Larsen" <pk*****@mailme.dk> wrote in message
news:iy*********************@news000.worldonline.d k...

"Barry Hynes" <hy****@mar.dfo-mpo.gc.ca> skrev i en meddelelse
news:zk*******************@ursa-nb00s0.nbnet.nb.ca...
Hi Folks,

still on the linked list problem...

how hazardous is the following code...i realize i do not have
copy/assignment defined and there is no exception handling...but was
wondering about the stl::list constructor and destructor.

i cannot inherit stl::list's ctor or dto - i think. Do not know how to
properly create/breakdown base class

any help greatly appreciated

Barry

// safeList.h

#ifndef SAFELIST_H
#define SAFELIST_H

using namespace std;
#include <list>
#include <iterator>
#include <memory>
#include <stdexcept>

//typedef list<T> S;
//typedef list<T>::iterator SI;

template<typename T>
class SafeList : private list<T> {
public:
SafeList() : list<T>() {}//No no-arg ctor not sure if i correctly
created an stl::list?
using list<T>::push_front;
using list<T>::size;
virtual ~SafeList() {}
No reason for a virtual destructor here. SafeList is NOT a list.
private:
// SafeList(const SafeList&);
// SafeList& operator = (const SafeList&);
};
#endif

#include <iostream>
#include "safeList.h"

using namespace std;

int main()
{
SafeList<int> SL;
SL.push_front(10);
SL.push_front(20);
SL.push_front(30);
SL.push_front(40);
cout << "The size of the list is: " << SL.size() << endl;
//i think i should call ~stl::list<T>...not sure

}

I see no problem but also I do not see what you solve. A list with only

some of the "goodies" available?
i am in the process of populating it with some goodies...slowly :)
but i was wondering if i actually got an stl::list up and running and didn't
send my PC in la la land when stl:list went out of scope

thanks for the help

Barry
/Peter

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
10
by: Greener | last post by:
Hi, I need help badly. Can you do client-side programming instead of server-side to capture the Browser type info? If this is the case, what's wrong with the following? <script...
4
by: Greener | last post by:
May I ask you the following? Two questions about the following block of code: 1) How to open the file in NON-ReadOnly mode? I tried many things, but none of them was working. 2) Any problems...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
6
by: dba | last post by:
using the following code with a problem.... echo "<input type='hidden' name='member_id' value=\"{$row}\">{$row}"; echo "<input type='radio' name='member_name' value=\"{$row}\">{$row}<br />"; ...
3
by: vrsathyan | last post by:
Hi.., While executing the following code in purifier.., std::vector<int> vecX; vecX.clear(); int iCount = 0; { int iVal;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.