In Exceptional C++, the following code snippet appears at the bottom of page
197:
template<class T>
class Array : private ArrayBase, public Container
{
typedef Array AIType;
public:
Array( size_t startingSize = 10 )
: Container( startingSize ),
ArrayBase( Container::GetT ype() ),
After this code snippet, the following paragraph appears:
1. If GetType() is a static member function, or a member function that does
not use its this pointer (that is, uses no member data) and does not rely on
any side effects of construction (for example, static usage counts), then
this is merely poor style, but it will run correctly.
What am I missing here? Since when can a non-static member function ever be
called except through a concrete object? Container::GetT ype() is not a
valid call if GetType() is not static!!!! Surely I must be missing
something incredibly obvious here! Somebody, please set me straight!!! 1 7012
Dave wrote: In Exceptional C++, the following code snippet appears at the bottom of page 197:
template<class T> class Array : private ArrayBase, public Container { typedef Array AIType; public: Array( size_t startingSize = 10 ) : Container( startingSize ), ArrayBase( Container::GetT ype() ),
Container::GetT ype() >>> this refers to the inherited Container object After this code snippet, the following paragraph appears:
1. If GetType() is a static member function, or a member function that does not use its this pointer (that is, uses no member data) and does not rely on any side effects of construction (for example, static usage counts), then this is merely poor style, but it will run correctly.
Which inherited object gets constructed first ? The ArrayBase or the
Container ? The point is that Container::GetT ype() gets called before
the Container object is constructed - hence the assertion that of the
undefined nature of the GetType() call. However, I'd say that the
result is plain undefined and you'd be far better off using a static
member function.
What am I missing here? Since when can a non-static member function ever be called except through a concrete object? Container::GetT ype() is not a valid call if GetType() is not static!!!! Surely I must be missing something incredibly obvious here! Somebody, please set me straight!!!
Another example - which is what I originally thought you were thinking :
class FooBar
{
public:
void Method()
{}
};
int main()
{
FooBar * x = 0;
x->Method();
//^^^^^^^^^^^^^^^ ^^^^^^^^^^^ Undefined behaviour
}
Even though this is undefined, it will run quite happily on most
platforms - BUT it's really just plain wrong and it's not worth the risk
(as it is for any undefined behaviour). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bhennon |
last post by:
Hey all,
I have a small php script that calls a random image at the following
page.
http://www.2006ymcanationals.com/random.php
IT WORKS IF I go directly to the above link.
I am trying to call that in another page so that i get a random image
the page is http://2006ymcanationals.com/index.php using <img
|
by: komal |
last post by:
hi all
basically my problem is i have to write a function such that when ever
i call this function in some other function .it should give me tha data
type and value of calling function parameter.and no of parameter is
calling function can be anything.
for example.suppose my function is function2.
then when i call
function1(int i ,char j,float d)
{
function2()
|
by: Ian Sedwell |
last post by:
Hi guys
Many thanks to all who replied to my original question. Actually, it's dead
easy and the way I was doing it was correct the first time. You do indeed
simply call the VBScript routine from the JavaScript routine. It doesn't
matter whether the scripts are in external files, or embedded in the HTML
document, so long as the VBScript is loaded before it is called from
JavaScript - obviously.
The VBScript routine can return a result...
|
by: Giulio Belrango |
last post by:
Hi I need someones help
I'm working in an IBM 390 batch environment.
What I'm trying to do is to call from a non DB2 COBOL program a DB2 COBOL
program that will access a table and perform an edit. I have several
programs to add this to and I thought of adding a common subroutine versus
adding duplicate code would be easier to maintain. The problem is from the
calling COBOL program to the calle COBOL program I get a -924 (which is no
DB2...
|
by: Martin Feuersteiner |
last post by:
Dear Group
I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My
code is something like this:
VB Code:
Public Sub VBProcedure()
..
..
| |
by: Sathyaish |
last post by:
/* I am writing this C# program because I forgot the syntax for
calling a parameterized constructor from a non-parameterized one
within the same class.
I was coding in Java and just typed it like this:
public MyClass(String someParam)
{
}
|
by: Jeronimo Bertran |
last post by:
Hello,
I have a WCF service that I am using to upload files to a server by using
the streamed transfer method. I am currently calling the service from a
WCF client. All I did was add a Service Refrence to my Windows Forms
project using VS2008.
I now want to allow non WCF clients to use the service. How can I do this?
Thanks,
|
by: dhtml |
last post by:
Array.splice({})
What should it do?
I think it should return a new Array with length 0.
Array.splice(arr, start, deleteCount ]])
http://bclary.com/2004/11/07/#a-15.4.4.12
Example:
|
by: Joe, G.I. |
last post by:
I didn't write ClassA, but I'm trying to inherit from ClassA through
ClassB. I want to pass a string to the ClassA constructor but not sure
I'm calling ClassA's constructor correctly. I get the following g++
error ...
In constructor 'ClassB::ClassB(String&)':
../../../include/ClassB.h:19: error: expected `{' at end of input
ClassB *myClass = new ClassB("myClassName");
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |