Search Results

Search found 15087 results on 604 pages for 'copy constructor'.

Page 8/604 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Ambiguous constructor call

    - by Crystal
    I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous." I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok. Here is my code: header file: #ifndef DATE_H #define DATE_H using std::string; class Date { public: static const int monthsPerYear = 12; // num of months in a yr Date(int = 1, int = 1, int = 1900); // default constructor Date(); // uses system time to create object void print() const; // print date in month/day/year format ~Date(); // provided to confirm destruction order string getMonth(int month) const; // gets month in text format private: int month; // 1 - 12 int day; // 1 - 31 int year; // any year int checkDay(int) const; }; #endif .cpp file #include <iostream> #include <iomanip> #include <string> #include <ctime> #include "Date.h" using namespace std; Date::Date() { time_t seconds = time(NULL); struct tm* t = localtime(&seconds); month = t->tm_mon; day = t->tm_mday; year = t->tm_year; } Date::Date(int mn, int dy, int yr) { if (mn > 0 && mn <= monthsPerYear) month = mn; else { month = 1; // invalid month set to 1 cout << "Invalid month (" << mn << ") set to 1.\n"; } year = yr; // could validate yr day = checkDay(dy); // validate the day // output Date object to show when its constructor is called cout << "Date object constructor for date "; print(); cout << endl; } void Date::print() const { string str; cout << month << '/' << day << '/' << year << '\n'; // new code for HW2 cout << setfill('0') << setw(3) << day; // prints in ddd cout << " " << year << '\n'; // yyyy format str = getMonth(month); // prints in month (full word), day, year cout << str << " " << day << ", " << year << '\n'; } and my main.cpp #include <iostream> #include "Date.h" using std::cout; int main() { Date date1(4, 30, 1980); date1.print(); cout << '\n'; Date date2; date2.print(); }

    Read the article

  • OpenERP model tracking external resource, hooking into parent's copy() or copy_data()

    - by CB.
    I have added a new model (call it crm_lead_external) that is linked via a new one2many on crm_lead. Thus, my module has two models defined: an updated crm_lead (with _name=crm_lead) and a new crm_lead_external. This external model tracks a file and as such has a 'filename' field. I also created a unique SQL index on this filename field. This is part of my module: def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} default.update({ 'state': 'new', 'filename': '', }) ret = super(crm_lead_external, self).copy(cr, uid, id, default, context=context) #do file copy return ret The intent here is to allow an external entity to be duplicated, but to retarget the file path. Now, if I click duplicate on the Lead, I get an IntegrityError on my unique constraint. Is there a particular reason why copy() isn't being called? Should I add this logic to copy_data()? Myst I really override copy() for the lead? Thanks in advance.

    Read the article

  • Free solution to backup folders to external SFTP server with shadow copy

    - by Sergiy Byelozyorov
    I have an account in university on Linux machine with 10TB of free space accessible via SFTP. I would like to backup my Windows 7 x64 laptop to university. Currently I am using rsync+cygwin, but backup is pretty slow (without shadow copy) and I hate console window appearing every day on my screen when I login. So I am looking for something like Windows Backup but with support for SFTP. Combination of tools will work too.

    Read the article

  • How to copy text from Console2?

    - by GJ
    I just started using Console2 as an alternative to cmd.exe I can't figure out how to copy text from the console to the clipboard -- dragging over it with the mouse won't mark anything, and there is no option in the right-click menu to "mark" as in cmd.exe It must be terribly obvious but I guess I'm overlooking it... :(

    Read the article

  • Vim: Copy selection

    - by Boldewyn
    Having a chunk of text selected in Vim's visual mode, I'd like to copy that to the system's clipboard (be it the primary or X11's). Is there an easy solution for this? Obviously, a simple y doesn't do the trick.

    Read the article

  • Copy data from a remote Linux box to my Windows desktop

    - by Sanjay Rao
    I use Putty to login to the remote server and then set the environment and change the path to a particular directory. Now from this dir, I need to copy a folder to my desktop which is Windows? How can I achieve this ? Some of my failed attempts are as follows scp -r remote_foldername srao@my_ipaddress:C:\srao\Users\Desktop So from the remote server which is to be copied through putty, to my_username_in_windows@ip_address:path to destination

    Read the article

  • Stop excel from converting copy-pasted number/text values to date

    - by Tomas
    I'm copy-pasting some data from html table into excel. But excel automatically converts some text or number values to date! When I change the format, the number is perversed, the number is something like 4112523 (excel probably interprets the cell as date and then converts to number or something like that...) There is a trick for importing CSV files, but is there any solution when you are pasting your data directly from a web browser?

    Read the article

  • looking for a command line tool to copy files to remote computers (similar to psexec)

    - by hatchetman82
    hi. im looking for a small utility that can copy files over to/from remote windows hosts, and which can take the credentials (domain user and password) as part of its command line, similar to psexec. i know i can use net use to map the target directory to a drive letter and use xcopy, and i know psexec can upload files to be executed on the remote machine and then delete them, but im looking for a small utility to distribute files to remote hosts that will not be as awkward to use as net use + xcopy

    Read the article

  • Accessing the constructor by using Reflection

    - by Md. Rashim Uddin
    Assume the class is public and and the constructor is internal like as Public class A { private string text; internal A(string submittedText); public string StrText { get; } } In this case how could I Access the constructor by using Reflection. What I have done so far Type[] pTypes = new Type[1]; pTypes[0] = typeof(object); object[] argList = new object[1]; argList[0] = "Some Text"; ConstructorInfo c = typeof(A).GetConstructor (BindingFlags.NonPublic | BindingFlags.Instance, null, pTypes, null); A foo = (A)c.Invoke(BindingFlags.NonPublic, null, argList, Application.CurrentCulture); But it shows an error. Any Suggestions

    Read the article

  • Accomplishing boost::shared_from_this() in constructor via boost::shared_from_raw(this)

    - by Kyle
    Googling and poking around the boost code, it appears that it's now possible to construct a shared_ptr to this in a constructor, by inheriting from enable_shared_from_raw and calling shared_from_raw(this) Is there any documentation or examples of this? I'm finding nothing with google. Why am I not finding any useful buzz on this on google? I would have thought using shared_from_this in a constructor would be a hot/desirable item. Should I be inheriting from both enable_shared_from_raw and enable_shared_from_this, and restricting my usage of enable_shared_from_raw when I have to? If so, why? Is there a performance hit with shared_from_raw?

    Read the article

  • Const parameter at constructor causes stackoverflow

    - by Luca
    I've found this strange behavior with VS2005 C++ compiler. Here is the situation: I cannot publish the code, but situation is very simple. Here is initial code: it work perfectly class Foo { public: Foo(Bar &bar) { ... } } The constructor implementation stores a reference, setup some members... indeed nothing special. If I change the code in the following way: class Foo { public: Foo(const Bar &bar) { ... } } I've added a const qualifier to the only constructor routine parameter. It compiles correctly, but the compiler outputs a warning saying that the routine Foo::Foo will cause a stackoverflow (even if the execution path doesn't construct any object Foo); effectively this happens. So, why the code without the const parameter works perfectly, while the one with the const qualifier causes a stackoverflow? What can cause this strange behavior?

    Read the article

  • Constructor Type Coercion in C++

    - by Robert Mason
    Take the following class: class mytype { double num; public: mytype(int a) { num = sqrt(a); } void print() { cout << num; } } Say there is a method which takes a mytype: void foo(mytype a) { a.print(); } Is it legal c++ (or is there a way to implement this) to call foo(4), which would (in theory) output 2? From what I can glean you can overload type casts from a user defined class, but not to. Can constructor do this in a standards-compliant manner (assuming, of course, the constructor is not explicit). Hopefully there is a way to in the end have this legal: int a; cin >> a; foo(a); Note: this is quite obviously not the actual issue, but just an example for posting purposes. I can't just overload the function because of inheritance and other program-specific issues.

    Read the article

  • C# - Adding to an existing (generated) constructor

    - by Vaccano
    I have a constructor that is in generated code. I don't want to change the generated code (cause it would get overwritten when I regenerate), but I need to add some functionality to the constructor. Here is some example code: // Generated file public partial class MyGeneratedClass { public MyGeneratedClass() { Does some generated stuff } } The only solution I can come up with is this: // My hand made file public partial class MyGeneratedClass { public MyGeneratedClass(bool useOtherConstructor):this() { do my added functinallity } } I am fairly sure this will work, but I then have a lame unused param to my constructors and I have to go change them all. Is there a better way? If not that is fine, but I thought I would ask.

    Read the article

  • Passing dependent objects to a parent constructor in Scala

    - by Nick Johnson
    Suppose I have the following class heirarchy: class A() class B(a:A) class C(b:B) class BaseClass(b:B, c:C) Now I want to implement a subclass of BaseClass, which is given an instance of A, and constructs instances of B and C, which it passes to its superclass constructor. If I could use arbitrary expressions, I'd do something like this: b = new B(a) c = new C(b) super(b, c) Because the second argument to the parent constructor depends on the value of the first argument, though, I can't see any way to do this, without using a factory function, or a gratuitous hack, such as : class IntermediateSubclass(b:B) extends BaseClass(b, new C(b)) class RealSubclass(a:A) extends IntermediateSubclass(new B(a)) Is there clean way to do this?

    Read the article

  • Problem accessing base member in derived constructor

    - by LeopardSkinPillBoxHat
    Given the following classes: class Foo { struct BarBC { protected: BarBC(uint32_t aKey) : mKey(aKey) mOtherKey(0) public: const uint32_t mKey; const uint32_t mOtherKey; }; struct Bar : public BarBC { Bar(uint32_t aKey, uint32_t aOtherKey) : BarBC(aKey), mOtherKey(aOtherKey) // Compile error here }; }; I am getting a compilation error at the point indicated: error: class `Foo::Bar' does not have any field named `mOtherKey'. Can anyone explain this? I suspect it's a syntactical problem due to my Bar class being defined within the Foo class, but can't seem to find a way around it. This is simple public inheritance, so mOtherKey should be accessible from the Bar constructor. Right? Or is it something to do with the fact that mOtherKey is const and I have already initialised it to 0 in the BarBC constructor?

    Read the article

  • C# COM+ component isn't getting the constructor string

    - by Kyle W
    I've created a COM+ component in C# with a strong name, COM Visible, ProgId, etc... I've then registered the assembly with regasm, and imported it into the COM+ Applications in Component Services. It runs just fine, and loads up the DLL, except that the constructor string that is passed in is always empty. The method signature is protected override void Construct(string constructString), and it is being called before the method on the actual component. In the component details in COM+ Applications, the constructor string is checked and a value is entered. Any help is appreciated.

    Read the article

  • Constructor/Destructor involving a class and a struct

    - by Bogdan Maier
    I am working on a program and need to make an array of objects, specifically I have a 31x1 array where each position is an object, (each object is basically built out of 6 ints). Here is what I have but something is wrong and i could use some help thank you. 31x1 struct header" const int days=31; struct Arr{ int days; int *M; }; typedef Arr* Array; 31x1 matrix constructor: void constr(){ int *M; M = new Expe[31]; // Expe is the class class header: class Expe { private: //0-HouseKeeping, 1-Food, 2-Transport, 3-Clothing, 4-TelNet, 5-others int *obj; } Class object constructor: Expe::Expe() { this->obj=new int[6]; } help please... because i`m pretty lost.

    Read the article

  • C++ constructor problem, values not being set

    - by 2Real
    Hi, I'm new to C++ and I'm trying to figure out this problem I'm having with my constructor for one of my classes. What happens is... all my variables are initialized properly except two (health and type). #pragma once #include <irrlicht.h> #include <vector> #include <cassert> using namespace irr; using namespace core; using namespace scene; enum { PLAYER = 0, NPC = 1, SOLDIER = 2, CHAINGUNNER = 3 }; class Model { public: Model(void); Model(int id, std::vector<ISceneNode*> modelVec, int modType); ~Model(void); std::vector<int> path; std::vector<ISceneNode*> model; int endNode; int type; int animate; int health; u32 lastAnimation; private: int mId; }; #include "Model.h" Model::Model(void) { //assert(false); } Model::Model(int id, std::vector<ISceneNode*> modelVec, int modType) { path = std::vector<int>(); model = modelVec; endNode = 0; type = modType; animate = 0; health = 100; lastAnimation = 0; mId = id; } Model::~Model(void) {} I create a model with Model soldier(id, model, SOLDIER) Everything is set properly except type and health. I've tried many different things, but I cannot figure out my problem. I'm not sure but the default constructor is being called. It doesn't make sense because I make no called to that constructor. Thanks,

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >