problem about public-Collection of common programming errors


  • Geri
    javascript namespaces constants public
    This question already has an answer here:Using a variable for a Javascript object key3 answersI want to use string constants instead of direct strings across my Javascript objects (when defining parameter keys, etc.). The purpose is to have my code indexed by IDE, have suggestions, auto-corrections / completitions, all the error-proof goodies.I want to define explicit keys for the constructor of this class EPPZObject, so I did:var EPPZ = {width: ‘width’,height: ‘height’ }var EPPZObject = Class.e

  • TheDarkIn1978
    actionscript-3 class function call public
    since the MXMLC compiler doesn’t support mixed access modifiers for setters/getters, i would like to know whether a public setter function is being called from inside or outside of the setter’s class. this approach should allow me to maintain a public property but with more security, something like public/private hybrid access.is it possible to use arguments’ callee property, or perhaps something else, to determine whether the setter was set internally from the setter’s class or if it was set e

  • Orodshsen
    c# private encapsulation public
    I’ve read some things about this, I even found similar question, but it didn’t really answer this. For me it seems that privatizing something only makes my life so much harder when I need to find a private variable in a class to use it elsewhere. So what is would the problem be if everything was public? Would it somehow slow the program itself?

  • gturri
    php variables time public
    when I do this :public $time = time();I have an error :Parse error: syntax error, unexpected ‘(‘, expecting ‘,’ or ‘;’.I don’t know why, Thank you a lots.

  • user3287603
    php parsing magento syntax public
    I changed something in my “redirect base url” options on the magento admin page. However, that didnt work out that well. After that I got the following error:Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in …./public_html/app/code/core/Mage/Core/Model/Config.php on line 662With the code:public function setNode($path, $value, $overwrite = true) {if ($this->_useCache && ($path !== null)) {$sectionPath = explode(‘/’, $path);$config = $this->_getSectionConfig($sectionPat

  • 1800 INFORMATION
    c# .net public internal
    I’m a pretty new C# and .Net developer. I recently created an MMC snapin using C# and was gratified by how easy it was to do, especially after hearing a lot of horror stories by some other developers in my organisation about how hard it is to do in C++.I pretty much went through the whole project at some point and made every instance of the “public” keyword to “internal”, except as required by the runtime in order to run the snapin. What is your feeling on this, should you generally make classes

  • eljenso
    java field private encapsulation public
    I have a data class in my application. My application will never be used as a public API and I will be the only person developing code within my project. I am trying to save every ounce of processor and memory power I can. Is it a bad idea to make my data members in my data class to have public/protected/default protection so that I don’t have to use a getter? Using a getter would require slightly more memory and creation of a stack and such…which I believe isn’t necessary. The only reaso

  • Patrick D’Souza
    c# winforms textbox controls public
    Hi i have code that create new variable for textbox that not exist yet, but can be created on runtime. it work great, see code bellowpublic void btnApagar_Click(object sender, EventArgs e) {TextBox txtAcessorio4 = (TextBox)gpbCategoria.Controls.Find(“txtAcessorio4”, false).FirstOrDefault();if (txtAcessorio4 != null && txtAcessorio4.Text == “” && lblAcessorio4.Name == “lblAcessorio4”){MessageBox.Show(“Perfect”);} }problem that i would like to use this created variable on another p

  • BrendanMcK
    asp.net user-controls properties public
    I have included a user control in another statically following code :place the folowing directive in the asp code of the parent page or usercontrol:<%@ Register src=”Name_of_your_child_control.ascx” tagname=”Name_of_your_child_control” tagprefix=”uc1″ %>use the following tag in the asp-code of the parent page/control:<uc1:Name_of_your_child_control ID=”Name_of_your_child_control1″ runat=”server” />….. But the issue is…i am not able to access the public properties of user control

  • HitomiTenshi
    c++ qt timer public
    I have a QMainWindow that connects 2 buttons with 2 functions. I want to start the QTimer with the StartBTNClick function and stop the QTimer with the StopBTNClick function. My problem is, that the QTimer is not defined in StopBTNClick, that’s why I want to know how to define a public QTimer. (btw. I’m new to C++, please bear with me)This is my code so far:MyClass::MainWindow(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags) {ui.setupUi(this);statusBar()->showMessage(“Status: Idl

  • Chris Cummins
    java static private public final
    In Java, it’s taught that variables should be kept private to enable better encapsulation, but what about static constants? This:public static final int FOO = 5;Would be equivalent in result to this:private static final int FOO = 5; … public static getFoo() { return FOO; }But which is better practice?

  • gremo
    php reflection public protected
    Problem: I don’t want to expose $myProperty, that is it shouldn’t be public, but I need it to be public just for __toString():class A {protected $myProperty;public function __toString(){return json_encode($this);} }I know that ReflectionProperty class has a method named setAccessible(), but how I’m supposed to use it before returning the string?EDIT: as per comments, I need compatibility with PHP 5.3.x, that is no JSonSerializable class.

  • Cristian Contreras
    objective-c methods private setter public
    #import “PsychologistViewController.h” #import “HappinessViewController.h”@interface PsychologistViewController() @property (nonatomic) int diagnosis; @end@implementation PsychologistViewController@synthesize diagnosis = _diagnosis;-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{if ([segue.identifier isEqualToString:@”ShowDiagnosis”]) {[segue.destinationViewController setHappiness:self.diagnosis];} else if ([segue.identifier isEqualToString:@”Celebrity”]) {[segue.destinationV

  • easycheese
    android variables public
    I have a public variable set in my Main Activity that declares the App as the free version or paid (boolean). I am receiving a lot of crash errors (null pointer exceptions) when it is accessed from a separate activity. I can’t reproduce this error on test devices so I can only assume that Android loses the Main Activity Variable when it is low on memory?Typically this happens when my users navigate to the browser to download a file and then navigate back to my App.Should I be setting a variabl

  • flashvnn
    php api facebook stream public
    I build a facebook app with php api, everything work fine just have a problem when i need public a message on user’s Wall. my code bellow$appapikey = “xxxxxx”; $appsecret = “xxxxxx”; $facebook = new Facebook($appapikey, $appsecret); $fb_user = $facebook->require_login(); if (!$facebook->api_client->users_hasAppPermission(“publish_stream, status_update”)){echo ‘<fb:prompt-permission perms=”publish_stream, status_update”>Click here to grant permissions to update your status and publ

  • Sam Miller
    c++ visual-c++ c++11 public visual-c++-2010
    I have a base class A and derived class Bclass B is derived from A as public I want to access the member variable’s address if A is class a is member variable I am observing different behavior when i am using protected and public access specifier.When member a of class A is protected in this case i am getting:cout<<&A::a << endl; throwing me an compiler error..but cout<<&(A::a)<<endl; is valid and giving me proper result.and When member a of class A is public in

  • user2660558
    jquery plugins methods call public
    I´ve tried a jQuery Plugin Boilerplate from this Site : jQuery_boilerplate, but i can´t call the public Method fooBar. My implemantion looks like:/*** jQuery lightweight plugin boilerplate* Original author: @ajpiano* Further changes, English comments: @addyosmani* More further changes, German translation: @klarstil* Licensed under the MIT license*/ ;(function ( $, window, document, undefined ) {“use strict”;var pluginName = ‘defaultPluginName’,defaults = {propertyName: “value”}; var privateMe

  • Alnitak
    javascript class private public
    i have this class:function ctest() {this.var1 = “haha”;this.func1 = function() {alert(this.var1);func2();alert(this.var1);}var func2 = function() {this.var1 = “huhu”;} }and call it :var myobj = new ctest();myobj.func1();isn’t supposed that the second alert will popup “huhu” ? func2 is private, can it not access the var1 public variable ?if a private function cannot access a public variable, how can i do it ?Thanks in advance!

  • Chagemei
    javascript public prototype-programming
    I want to create a simple class in Javascript with only one public function as follows:function A(myTitle) { var title = “”;this.getTitle = function() {return title;};title = myTitle; };var anInstance = new A(“first”); console.log(“anInstance.getTitle(): ‘”+anInstance.getTitle()+”‘”); // expecting to return “first”This does work as expected.Now I want to add this class as a prototype to a new class, that includes a new title variable, so that the getTitle() method returns the value of the varia

  • TiansHUo
    java class public protected
    I’m new to Java and OOP,I was using a private subclass (actually a struct) B in a class A, and everything went well until I decided to make a parent class C for subclass B. I want make public some of the protected members of class C. For example:public class A {private class B extends C {public int product;public int x;public int y;public void add() {product=x+y;}}B b=new B;b.x=1;b.y=2;b.multiply();System.out.println(b.product+”=”+b.x+”x”+b.y);public class C {protected int x;protected int y;pub

  • sygad1
    jquery plugins methods public creation
    I have created a plugin to convert an HTML select box into a custom drop down using DIV’s.All works well, but i’d like to make it a little better. see my jsFiddleAt the end of the plugin I have 2 methods, slideDownOptions & slideUpOptions, I would like to make these available outside of the plugin so other events can trigger the action.Im getting a little confused how to do this and more specifically how to call the methods from both within the plugin AND from outside of the plugin.Any help

  • WilliamKF
    c++ public protected dynamic-cast
    I changed my C++ base class to be protected inheritance and my dynamic_cast(s) stopped working.Why should changing the inheritance to protected change the behavior of dynamic_cast?struct Base {static Base *lookupDerived(); // Actually returns a Derived * object. };struct Derived : protected /* Switch this to public to get it working */ Base {static void test() {Base *base = lookupDerived();if (dynamic_cast<Derived *>(base)) {std::cout << “It worked (we must be using public inheritanc

  • Laurent
    c++ class enums public
    I’m a bit confused with an error I’m having right now. I have a getter/setter in my class. The setter takes an enum as a parameter and the getter should return this enum. However, I’m getting this error for the getter:error: C2143: syntax error : missing ‘;’ before ‘Session::type’as if SessionType was undefined. However I’m not getting the same error for the setter. Is there any reason why? And is there any way to fix this error?(by the way, it compiles fine if I return an int but I’d rather kee

  • PowerPC
    c++ class function pointers public
    This question already has an answer here:Accessing class members on a NULL pointer7 answersWhen does invoking a member function on a null instance result in undefined behavior?2 answersHow does below program prints “Show Called” ? I guess it should have been run-time error since value of obj ptr is NULL.#include<iostream> using namespace std;class ex{int i;public:ex(int ii=0):i(ii) {}~ex(){cout<<“dest”<<endl;}void show(){cout<<“Show called”;}};int main(){ex *obj = NULL;ob

  • Pardoner
    javascript jquery jquery-plugins methods public
    I’ve been using the below boilerplate for jQuery Plugin development which has been working great. But I’m not sure of the best way to make a “method” public.;(function ( $, window, undefined ) {var pluginName = ‘defaultPluginName’,document = window.document,defaults = {propertyName: “value”};function Plugin( element, options ) {this.element = element;this.options = $.extend( {}, defaults, options) ;this._defaults = defaults;this._name = pluginName;this.init();}Plugin.prototype.init = function ()

  • scientiffic
    ruby-on-rails activity public
    In my Rails app, I am trying to pass a local variable to a public_activity partial. I have my comments model tracked using public_activity, and I render the comments using:<%= render_activity(activity, :locals => {:source => “notifications”})%>Then in views/public_activity/comment/_create.html.erb, I try to use the source variable I passed to the partial:_create.html.erb<%= source %>However, I get the error “undefined local variable ‘source'”How can I pass a variable to my pub

  • Jackson
    ios static constants public extern
    I’m trying to accomplish a C style version of public static constWhat I tried doing already:ClassA.hextern const int FEATURES;ClassA.m#define THE_CONST 123ClassB.b#import ClassA.h initWithFrameFEATURESXcode does not through a runtime error, but rather a build error of undefined symbols for architecture i386: “_THE_CONST”, referenced from: …How can I share an extern const to for another class to use as well?

  • gaidal
    vb.net class shared public option-strict
    One of my classes seems to be invisible to the rest of my project. I wonder if I somehow have to initialize it before I can use its public stuff.The functions and methods of Class1 immediately appear in IntelliSense, but Class2 is treated like a general (unknown) object. I have some Public Shared functions in Class1 and Class2. I can call functions usingClass1.myPublicSharedFunction()normally. However when I try this with any function from Class2, I get the error:Error 1 Option Strict On di

  • billz
    c++ inheritance constructor public protected
    I have a project going with multiple levels of inheritance. It goes like thisXMLs -> Entity -> Item and then there are numerous item classes that inherit from Item which then inherit from Entity. Now, I have each class defined as shownclass Entity: public XMLs{public: Entity() {}virtual ~Entity() {};//other functions};This is the one that is giving me trouble. Whenever I try to create an Item object or any type of object at all really in my main function, it gives me the following error/us

  • leppie
    flash class variables movieclip public
    Sorry for simple question, but…I have DocumentClass which has public variable kTemp:public var kTemp:Number = 0; I Also have Movie Clip which has some internal timeline code with this fragment: var counter1:int = 0; counter1 = kTemp; Strangely enough, but the last line gives an error:1120: Access of undefined property kTemp. counter1 = kTempWhat am I doing wrong? I though that global variables are seen from everywhere. What is the simplest method to get value of public variable inside mov

Web site is in building