06-28-2010
Quote:
Originally Posted by
Corona688
I don't see any similarity in design or inheritance between what you're trying to do and and the example you quote... I don't think the constructor is what lets it do that, are you sure that's the complete code? No external operator functions? Also: You can't cast one value into two values.
The code is taken from:
PHP Code:
http://newdata.box.sk/bx/c/htm/ch15.htm
see listing 15.1 and 15.2. Most of the code is exactly the same as the one I posted with the exception of the main function. According to the book -and I debugged it in order to verify it- this behavior is due to the constructor from String.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi guys I am new to these forums but since I am taking a class at college I would appreciate any help that is possible for this program. My instructor said that when its complete the program should be able to store all 3 fields instead of just 1.
public class Greeter2Test
{
public static... (4 Replies)
Discussion started by: woot4moo
4 Replies
2. Programming
helo i read many books but i cant find the proper answer that why
constructor cannot be virtual
can u explain me in simple term that why constructor cannot be virtual
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
3. Programming
helo i m new in c++ on linux
can u tell me with an simple example that how do you handle constructor and destructor that fail?
Regards,
Amit (4 Replies)
Discussion started by: amitpansuria
4 Replies
4. Programming
Hi All,
I have made the simple following program :-
#include <string>
#include <iostream>
using namespace std;
class A{
private: int val;
public :
A(){cout<<"In A()"<<endl;}
A (const A& aa)
{
cout<<"In copy c'tor"<<endl;
}
};
A f(... (1 Reply)
Discussion started by: shubhranshu
1 Replies
5. UNIX for Dummies Questions & Answers
I am new to PHP and UNIX. I am using Apache to do my testing on a Windows Vista machine.
I am getting this error when I am trying to connect to a web service. I did a search and did not see any posts that pertain to this.
Here is my function:
<?php
function TRECSend($a, $b, $c, $d,... (0 Replies)
Discussion started by: EddiRae
0 Replies
6. Programming
I have a code as following:
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
//the class Nth is a predicates
class Nth{
private:
int nth;
int count;
public:
Nth(int n):nth(n),count(0){}
bool operator()(int){
... (2 Replies)
Discussion started by: homeboy
2 Replies
7. Programming
Hello,
I am new to programming shared objects and I was hoping someone could tell me if what I want to do is possible, or else lead me in the right direction.
I have a main program that contains an abstract base class. I also have a subclass that I'm compiling as a shared object. The subclass... (13 Replies)
Discussion started by: dorik
13 Replies
8. Programming
Hi,
If I run the following program
class A {
public:
A() { cout << "default" << endl; }
A(const A&) { cout << "copy" << endl; }
};
A tmp;
A fun() {
return tmp;
}
A test() {
A tmp;
cout << &tmp << endl;
return tmp;
} (1 Reply)
Discussion started by: royalibrahim
1 Replies
9. Programming
I am learning about C++ and today am reading concepts for Constructor but it seems a bit difficult to grab it fully. Please anyone explain in simple words about Constructor? (1 Reply)
Discussion started by: ggiwebsinfo
1 Replies
10. Programming
How to initialize an object of class say "A", with an object of type say "B".
The following code give the error message "error: conversion from âAâ to non-scalar type âBâ requested"
#include <iostream>
using namespace std;
class B;
class A{
public:
A() { cout <<"\nA()" << endl; }
... (1 Reply)
Discussion started by: techmonk
1 Replies
VARIANT(3) 1 VARIANT(3)
VARIANT class
DESCRIPTION
The VARIANT is COM's equivalent of the PHP zval; it is a structure that can contain a value with a range of different possible types. The
VARIANT class provided by the COM extension allows you to have more control over the way that PHP passes values to and from COM.
$vVar = new VARIANT($var)
METHODS
VARIANT::VARIANT ([mixed $value], [int $type], [int $codepage])
VARIANT class constructor. Parameters:
o value
- initial value. if omitted, or set to NULL an VT_EMPTY object is created.
o type
- specifies the content type of the VARIANT object. Possible values are one of the VT_XXX"Predefined Constants". In PHP versions
prior to PHP 5, you could force PHP to pass a variant object by reference by OR'ing VT_BYREF with the $type. In PHP 5, this hack
is not supported; instead, PHP 5 can detect parameters passed by reference automatically; they do not even need to be passed as
VARIANT objects. Consult the MSDN library for additional information on the VARIANT type.
o codepage
- specifies the codepage that is used to convert strings to unicode. See the parameter of the same name in the "COM" class for
more information.
PHP versions prior to PHP 5 define a number of (undocumented) virtual properties for instances of the VARIANT class; these properties have
all been removed in PHP 5 in favour of its more natural syntax; these differences are best highlighted by example:
Example #1
Variant example, PHP 4.x style
<?php
$v = new VARIANT(42);
print "The type is " . $v->type . "<br/>";
print "The value is " . $v->value . "<br/>";
?>
Example #2
Variant example, PHP 5 style
<?php
$v = new VARIANT(42);
print "The type is " . variant_get_type($v) . "<br/>";
print "The value is " . $v . "<br/>";
?>
The reason for the change is that, internally, the COM extension sees VARIANT, COM and DOTNET classes as the same thing, and the design
philosophy for these classes is that all property and member accesses are passed through to COM with no interference. The new syntax is
more natural and less effort, and most of the removed virtual properties didn't make any sense in a PHP context in any case.
Note
PHP 5 takes a much simpler approach to handling VARIANTs; when returning a value or fetching a variant property, the variant is
converted to a PHP value only when there is a direct mapping between the types that would not result in a loss of information. In
all other cases, the result is returned as an instance of the VARIANT class. You can force PHP to convert or evaluate the variant as
a PHP native type by using a casting operator explicitly, or implicitly casting to a string by print(3)ing it. You may use the wide
range of variant functions to perform arithmetic operations on variants without forcing a conversion or risking a loss of data.
See also variant_get_type(3).
PHP Documentation Group VARIANT(3)