Sponsored Content
Top Forums Programming c++ object constructor question Post 302433480 by Corona688 on Tuesday 29th of June 2010 08:28:20 PM
Old 06-29-2010
I stand corrected, then. You still can't cast one parameter into two parameters, though. It could take a single class that had two members.

A better way to handle this case would be to overload function itself -- make another function of the same name that does in fact take two integers.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Constructor problem

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

why constructor cannot be virtual

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

how do you handle a constructor and destructor that fail

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

Doubt regarding Copy Constructor and return value

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

Object reference not set to an instance of an object

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

question about function object

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

Shared Object Question

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

Doubts on C++ copy constructor concept

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

Constructor?

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 with another object of different class?

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
Tangram::Complicity(3pm)				User Contributed Perl Documentation				  Tangram::Complicity(3pm)

NAME
Tangram::Complicity - How to make Tangram-friendly classes SYNOPSIS
package YourNastyXSClass; sub px_freeze { return [ (shift)->gimme_as_perl ]; } sub px_thaw { my $class = shift; my $self = $class->new( @_ ); } 1; DESCRIPTION
Tangram::Complicity does not exist. To make matters worse, it isn't even implemented. This page is a big FIXME for the code it refers to. This page merely documents the API that classes must implement to be safely stored by "Tangram::Type::Dump::flatten". Note that to avoid unnecessary copying of memory structures from A to B, this method operates "in-place". So, therefore it is necessary for the reference type used in the return value, to be the same as the one in the real object. This is explained later under "reftype mismatch". So - for instance, for Set::Object objects, which have a "px_freeze" method of: sub px_freeze { my $self = shift; return $self->members; } sub px_thaw { my $class = shift; return $class->new(@_); } [ note: This differs from the Storable API ("STORABLE_freeze" and "STORABLE_thaw"). This interface is actually reasonably sane - the Storable API required custom XS magic for Set::Object, for instance. Which has been implemented, but we've learned the lesson now :) ] In essence, the "px_freeze" method means "marshall yourself to pure Perl data types". Note that different serialisation tools will treat ties, overload and magic remaining on the structure in their own way - so, create your own type of magic (a la Pixie::Info) if you really want to hang out-of-band information off them. reftype mismatch If you get a "reftype mismatch" error, it is because your YourClass->px_thaw function returned a different type of reference than the one that was passed to store to YourClass->px_freeze. This restriction only applies to the return value of the constructor "px_thaw", so this is usually fine. The return value from "px_freeze" will be wrapped in a (blessed) container of the correct reference type, regardless of its return type. ie. your function is called as: %{ $object } = %{ YourClass->px_thaw(@icicle) }; @{ $object } = @{ YourClass->px_thaw(@icicle) }; ${ $object } = ${ YourClass->px_thaw(@icicle) }; *{ $object } = *{ YourClass->px_thaw(@icicle) }; my $tmp = YourClass->px_thaw(@icicle); $object = sub { goto $tmp }; This is an analogy, no temporary object is actually used in the scalar case, for instance; due to the use of tie. The reason for this is to allow for circular and back-references in the data structure; those references that point back point to the real blessed object, so to avoid the overhead of a two-pass algorithm, this restriction is made. This is why the value is passed into STORABLE_thaw as $_[0]. For most people, it won't make a difference. However, it does have the nasty side effect that serialisers that can't handle all types of pure Perl data structures (such as, all current versions of YAML) are unable to store blessed scalars (eg, Set::Object's). perl v5.8.8 2006-03-29 Tangram::Complicity(3pm)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy