namespaces

Operator overloading and namespaces [duplicate]

醉酒当歌 提交于 2019-12-29 07:27:07
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Where should non-member operator overloads be placed? While browsing on SO, I often find questions or answer that involves overloading/defining a std::ostream& operator<<(std::ostream& os, const Foo& foo) or a Foo operator+(const Foo& l, const Foo& r) . While I know how and when (not) to write these operators, I'm confused about the namespace thing. If I have the following class: namespace bar { class Foo {}; }

NameError using execfile in python

萝らか妹 提交于 2019-12-29 07:08:30
问题 My application has a button to execute a python script dynamically using execfile . If I define a function inside the script (eg. spam() ) and try to use that function inside another function (eg. eggs() ), I get this error: NameError: global name 'spam' is not defined What is the correct way to call the spam() function from within eggs() ? #mainprogram.py class mainprogram(): def runme(self): execfile("myscript.py") >>> this = mainprogram() >>> this.runme() # myscript.py def spam(): print

PHP class not found when using namespace

安稳与你 提交于 2019-12-29 05:32:07
问题 I am new with this namespace thing. I have 2 classes(separate files) in my base directory, say class1.php and class2.php inside a directory src/ . class1.php namespace \src\utility\Timer; class Timer{ public static function somefunction(){ } } class2.php namespace \src\utility\Verification; use Timer; class Verification{ Timer::somefunction(); } When I execute class2.php , i get the Fatal error that PHP Fatal error: Class 'Timer' not found in path/to/class2.php at line *** I read somewhere on

Changing Namespaces in Entity Framework

▼魔方 西西 提交于 2019-12-29 04:27:29
问题 I am trying to change the Namespace used by Entity Framework Generator of classes. When I click the designer of my Entity, Model.edmx, I can see somewhere where I can change the namespace: Namespace under ConceptualEntityModel properties. Changed that namespace, but nothing happened. Didn't work. So, I read some help from this link: http://weblogs.asp.net/zeeshanhirani/struggling-through-namespace-in-entity-framework says that I have to change the property: Custom Tool Namespace That's nice,

How to resolve Rails model namespace collision

风流意气都作罢 提交于 2019-12-29 04:22:23
问题 The story so far: I have a rails app with a model named "Term". All is well until trying to install Cucumber. Upon running rake cucumber I get Term is not a class (TypeError) This happens because Cucumber includes another gem, 'term-ansicolor' (to do the nifty colored text output in the console), and term-ansicolor defines a module named "Term". Cucumber includes term-ansicolor before including the Rails models, thus "Term" is already defined as a module when loading the "Term" model. Top

Adding multiple namespace declarations in XmlWriter

旧街凉风 提交于 2019-12-29 04:09:32
问题 I am trying to write out the following element using XmlWriter <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> I've got the very first declaration done using writer.WriteStartElement("kml", "http://www.opengis.net/kml/2.2"); How can I add the remaining 3 declarations to the same element? 回答1: writer.WriteAttributeString("xmlns","gx", null, "http://www.google.com/kml

How do I add multiple namespaces to the root element with XmlDocument?

跟風遠走 提交于 2019-12-28 14:43:40
问题 I need to create an XmlDocument with a root element containing multiple namespaces. Am using C# 2.0 or 3.0 Here is my code: XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("JOBS", "http://www.example.com"); doc.AppendChild(root); XmlElement job = doc.CreateElement("JOB", "http://www.example.com"); root.AppendChild(job); XmlElement docInputs = doc.CreateElement("JOB", "DOCINPUTS", "http://www.example.com"); job.AppendChild(docInputs); XmlElement docInput = doc

How do I add multiple namespaces to the root element with XmlDocument?

与世无争的帅哥 提交于 2019-12-28 14:43:17
问题 I need to create an XmlDocument with a root element containing multiple namespaces. Am using C# 2.0 or 3.0 Here is my code: XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("JOBS", "http://www.example.com"); doc.AppendChild(root); XmlElement job = doc.CreateElement("JOB", "http://www.example.com"); root.AppendChild(job); XmlElement docInputs = doc.CreateElement("JOB", "DOCINPUTS", "http://www.example.com"); job.AppendChild(docInputs); XmlElement docInput = doc

Namespaces with external linkage

删除回忆录丶 提交于 2019-12-28 13:59:02
问题 The problem I have is basically the same as 'greentype' mentions at http://www.cplusplus.com/forum/beginner/12458/ I'm sharing variables through namespaces and a problem arises when I try to put my function definitions into a separate file. Consider the following example, where I want to pass variable 'i', defined in the main code, to the function a(): * nn.h: * #ifndef _NN_H_ #define _NN_H_ namespace nn { int i; } #endif * main.cpp * #include <iostream> #include "nn.h" using namespace std;

Namespaces with external linkage

試著忘記壹切 提交于 2019-12-28 13:58:47
问题 The problem I have is basically the same as 'greentype' mentions at http://www.cplusplus.com/forum/beginner/12458/ I'm sharing variables through namespaces and a problem arises when I try to put my function definitions into a separate file. Consider the following example, where I want to pass variable 'i', defined in the main code, to the function a(): * nn.h: * #ifndef _NN_H_ #define _NN_H_ namespace nn { int i; } #endif * main.cpp * #include <iostream> #include "nn.h" using namespace std;