Sponsored Content
Top Forums Programming c++ object constructor question Post 302433176 by santiagorf on Monday 28th of June 2010 10:30:00 PM
Old 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

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

NAME
MooseX::Param - Simple role to provide a standard param method SYNOPSIS
package My::Template::System; use Moose; with 'MooseX::Param'; # ... my $template = My::Template::System->new( params => { foo => 10, bar => 20, baz => 30, } ); # fetching params $template->param('foo'); # 10 # getting list of params $template->param(); # foo, bar, baz # setting params $template->param(foo => 30, bar => 100); DESCRIPTION
This is a very simple Moose role which provides a CGI like "param" method. I found that I had written this code over and over and over and over again, and each time it was the same. So I thought, why not put it in a role? ATTRIBUTES
params This role provides a "params" attribute which has a read-only accessor, and a HashRef type constraint. It also adds a builder method (see "init_params" method below) to properly initialize it. METHODS
params Return the HASH ref in which the parameters are stored. param This is your standard CGI style "param" method. If passed no arguments, it will return a list of param names. If passed a single name argument it will return the param associated with that name. If passed a key value pair (or set of key value pairs) it will assign them into the params. init_params This is the params attribute "builder" option, so it is called the params are initialized. NOTE: You can override this by defining your own version in your class, because local class methods beat role methods in composition. meta Returns the role metaclass. SIMILAR MODULES
The "param" method can be found in several other modules, such as CGI, CGI::Application and HTML::Template to name a few. This is such a common Perl idiom that I felt it really deserved it's own role (if for nothing more than I was sick of re-writing and copy-pasting it all the time). There are also a few modules which attempt to solve the same problem as this module. Those are: Class::Param This module is much more ambitious than mine, and provides much deeper functionality. For most of my purposes, this module would have been overkill, but if you need really sophisticated param handling and the ability to provide several different APIs (tied, etc), this module is probably the way to go. Mixin::ExtraFields::Param This module is very similar to mine, but for a different framework. It works with the Mixin::ExtraFields framework. BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2007 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-03-29 MooseX::Param(3pm)
All times are GMT -4. The time now is 07:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy