c ++ – Can not initialize a private static member?

I am new to c ++ (python). I do not know how to initialize a private static member, according to this question. I have to boot it into a source file, but inside the source file, I have tried to boot 3 slots.

1.out side of any class or function -> declaration has no storage class or type specifier

2.a (main) function -> (declared in line 9) is inaccessible

3.inside a static method of the class -> no effect

and I do not know why I'm getting a link error:

error LNK2001: unresolved external symbol "private: static int I :: i" (? i @ I @@ 0HA)

where to boot it?

#define print (x) std :: cout << << << std :: endl;

class I
static int i;
static int geti ();
// I :: i = 1; declaration has no storage class or type specifier

int main ()
// I :: i = 1; (stated at line 9) is inaccessible
print (I :: geti ()); // link error!
returns 0;

int I :: geti ()
i = 1;
returns i;

Web Development – Is storing common static pages in a database a bad practice?

I am wondering if it is not advisable to store commonly used standard static web pages in a database, such as the homepage, the "Contact Us" page, the login page, and so on. rather than as static files stored on the server?

In particular, if so, does this apply when static web pages share a relatively large style with dynamically generated web pages?

I suspect the answer is that this is a bad practice because of the increased load times associated with connecting and recovering the database, but I have not done my own performance tests and I can not find any answer online. check.

ios – revision of the Swift code – static variables?

TLDR: (Sent here from StackOverflow) The code I presented works. I am looking for a code review from more experienced developers to find out if what I did is acceptable and to find out if there are better practices I should focus on to develop my skills and understanding .

Hello. I have finished version 1 of my first application (thanks to all the StackOverflow Q & A that brought me there). For version 2, I am looking to improve the code. I'm not sure this is the best place to request a code review, but I have not known or been self-taught for a month and I have no one to review my work.

I've listed 2 situations that I think I need to improve. If you have the time, I would like to have comments on my use of static variables to change the data between ViewControllers and subviews.

1.0 Figure 1 shows the flow of the application (Left = AccueilContrôleur), middle = MenuController, Right = FavorisContrôleur)

In AccueilContrôleur There is a UIView subview. From this sub-view, the current quote (HomeController.homeControllerCurrentQuote) displayed can be saved in favorites board. This is a static array defined in FavorisContrôleur.

The functions below are called from the subview in AccueilContrôleur. I did HomeController.homeControllerCurrentQuote static because the subview needs to access it. The same applies to FavorisContrôleur.favoris.

// FavoritesController.favourites is a static variable!
// HomeController.homeControllerCurrentQuote is a static variable! updated when the user scrolls

func handleFavourite () {
let favorites = FavoritesController.favourites
if favorites.contains (HomeController.homeControllerCurrentQuote) {
removeFavorites ()
} else {FavoritesController.favourites.append (HomeController.homeControllerCurrentQuote)
UserDefaults.standard.set (try? PropertyListEncoder (). Encode (FavoriteController.favourites), forKey: "myKey")

func removeFromFavourites () {
var tempArray: [Quote] = [.init(category: "", quote: "", author: "")]
    tempArray = FavoritesController.favourites
let searchString = HomeController.homeControllerCurrentQuote.quote
var filteredArray = [Quote]()
filterArray = tempArray.filter ({! $ 0.quote.contains (searchString)})
UserDefaults.standard.set (try? PropertyListEncoder (). Encode (filterArray), forKey: "myKey")

// update the static variable on HomeController
internal override function scrollcollViewDidEndDecelerating (_ scrollView: UIScrollView) {
HomeController.homeControllerCurrentQuote = Quote (category: cell.categoryLabel.text ?? "", quote: cell.quoteLabel.text ?? "", author: author)

Sure FavorisContrôleur the data contained in FavorisContrôleur.favoris array is used to populate a Tableview.

Image 1 Image 1

Should I change the way this is done? I do not like the use of static variables, but since this is my first application, I was more focused on doing it than on how it had been done. Is this a good case for using a to delegate and protocol to communicate between points of view (I have never used this before)? If so, how could I start thinking about implementing it or, as it works, what I have done is it satisfactory?

2.0 When the application starts on AccueilContrôleur the required data is generated and stored in a static variable.

                                                                                                        //  [category : [quote  : author]]xQuotesByCategory static var: [String   : [String : String]]= [:]

I make this data static because when I instantiate AccueilContrôleur again from another controller, I do not want to have to recover the data. I want to get it back once. Then when a new instance of AccueilContrôleur is called I can make this check that should go wrong. Is this an appropriate use of a static variable?

if HomeController.xQuotesByCategory.values.isEmpty {
... fetchJson ()

Following this, as HomeController.xCitationsParCatégorie is static, on CatégoriesContrôleur I can call

var categories = Array (HomeController.xQuotesByCategory.keys)

This is only outside Keywords (categories) that I use to create the collectionVoir cell with the text and images shown in the picture 2. Again, same question, is there an appropriate use of a static variable? Is there a better way to ensure that data is only loaded once, then Keywords at CatégoriesContrôleur in a different way when it is needed?

image 2

Sorry in advance if it's a bad question to ask for a code revision on update (StackExchange) StackOverflow, just try to learn here. In addition, to help beginners even more, a test version is available on TestFlight. if anyone really wants to see it for himself and give me more comments, please let me know and I can add you in TestFlight!

Long live, appreciate any help

wi fi – Is there a way to switch from dynamic wifi android network mode from static to static?

How can I switch the Android device wifi network mode from dynamic to static programmatically.
This means that I have to specify the IP address, the gateway and the DNS.

But how to do it all by programming ?!

I had studied it without finding any real solution.

Anyone can help?

Unity – Where should I start to create a 2D point-and-click game that presents static images like the classic Shadowgate game?

I can not seem to find a good reference for the specific type of 2D point-and-click adventure I'm thinking of. I would like to make a game that is in the vein of the classic game Apple / NDA Shadowgate. https://en.wikipedia.org/wiki/Shadowgate

Basically, there are completely static images in which you would click on the image to determine your way forward (or backward). This could be achieved with a compass or arrows somewhere on the user interface. It would be an entirely first-person perspective. You have an inventory that you can click to apply the photo quests and solve.

I use Unity, but it does not bother me to try something more suitable for the development of such a game. I have experience with C # mainly, c & # 39; Is therefore a consideration.

Basic static MPLS configuration for Cisco 3725 in GNS3

I need to transfer an MPLS packet from Router 1 to Router 2 (as shown in the table below). The connection summary is:
Cloud-1 <--> R1 <--> R2 <--> Cloud-2. I've also tried the basic static configuration for R1 interfaces and linking static label tags. I've also added routes for R1 (I'm trying on R1 only to see if he's able to transfer it to R2). Cloud-1 and 2 are virtual interfaces to a hardware device installed on the same server that GNS3 is running. It will send and receive packets labeled MPLS and I made sure of its smooth operation (that is, transmits MPLS packets to R1) and I can capture packets between Cloud-1 and R1 and I see the package sent from Cloud-1 to R2. These virtual interfaces function as PE routers because the packets will be labeled.


Here is the configuration for R1:

configure the terminal
ip mpls
no mpls ldp advertise-labels
FastEthernet0 / 1 interface
ip address
ip mpls
No extinguishment
configure the terminal
ip mpls
no mpls ldp advertise-labels
FastEthernet0 / 0 interface
ip address
ip mpls
No extinguishment
configure the terminal
no mpls ldp advertise-labels
Labels range 10001 labels 1048575 static 16 10000
Static links mpls ipv4 2222
Static link mpls ipv4 1001
static link mpls ipv4 output 3333
static link mpls ipv4 output 2002
ip route FastEthernet0 / 0
ip route FastEthernet0 / 1

The package that R1 will receive from Cloud-1 has as src IP and (a host that will be pointing to cloud 2). The MPLS label is 1001 in this package.

I do not see any packets being sent to R2.

This is the output of some of the relevant commands. Note that there is no entry in LFIB and I do not know why, as suggested by most Cisco site manuals and tutorials, there should be entries in the MPLS forwarding table regarding the static links that I have made.

R1 # show mpls label range
Downstream region of the generic label: Min / Max label: 10001/1048575
Static Label Range: Min / Max Count: 16/10000
R1 # static ipv4 show mpls Incoming label: 2222
Outbound labels: 3333 Incoming label: 1001
Outbound labels: 2002
R1 # show mpls forwarding-table
Local tag of outgoing prefix bytes
tag tag or VC or tunnel interface with switched interface
R1 #

The package sent to R1 looks like this (the destination MAC address is the MAC Fa0 / 0 of R1 in case this could be a reason for the deletion of packets, I guessed):

###[ Ethernet ]###
dst = c2: 02: 72: 6b: 00: 00
src = da: a5: a2: dd: 5c: 8b
type = 0x8847
###[ MPLS ]###
label = 1001L
exp = 0L
bos = 1L
ttl = 254
###[ IP ]###
version = 4L
ihl = 5L
tos = 0x0
len = 20
id = 1
flags =
frag = 0L
ttl = 64
proto = hopopt
chksum = 0x63e8
src =
dst =

Any help is appreciated.

wurm – In Würm, when does a bonus have to be an extra die and when is it a static value?

In Wurm, the actions are resolved by rolling 2d6 and exceeding a threshold for the challenge. Context, special abilities, and items may provide bonuses or penalties to this throw.

I will manage my first game of Wurm soon. I'm trying to build some intuition about the types of situations that warrant an unconditional bonus and the types that warrant a bonus die.

Here is an example. These two tasks involve that one player brings benefits to another character. Why is one stochastic and the other fixed? How can I choose the type of bonus to offer?

  • A character can perform a ceremony. Ceremony participants earn + 1d6 at some type of test. For example, a hunting ceremony could add a bonus to tracking down a buffalo
  • A character can play music provide a +2 or -2 for some checks. For example, a drummer may inspire the fear of providing -2 stable nerve checks.

Design model to expose static functions in C / C ++ only to unit tests

I have a few static free functions (not belonging to a class) in a C ++ file. I want them to always be visible in this module and that they are free, but I also want to test them with unit tests.

As far as I know, several options are possible:

  • Using macros, enable / disable the static keyword according to a variable or not (MODE OF TESTING) is defined or not:
#ifdef TEST_MODE
#define static
#end if
  • Use 'private headers': create a header file whose name ends with _private and whose location is in include / private.

  • Declare the functions of the normal header file by adding them as a private section with code comments. As /////// PRIVATE SECTION ///////

  • Include the * .cpp file in which they are declared (personally, I do not like this option at all)

  • Group the private functions into a private namespace. As namespace myNamespace {namespace private {....}}. The problem with this one is that it can not be used in clear C.

  • Use the compiler directives to hide things, like __attribute __ (("hidden"))

I would say that my favorite is the private header, it seems to be clean and does not require namespaces, in case the language does not support them.

Which is considered the best practice?

redirect – How to hide a subfolder of static pages in WordPress using htaccess

I need help please because I can not find a solution to my problem.

I have to hide a subfolder in the url of my wordpress site.

I created a subfolder where I downloaded static pages in php

Example: domain.com/subfolder/file.php

What I need is to remove / hide the "subfolder" to get the following:


I've tried a lot of htaccess codes found here but I still have a 404 error.

Thank you in advance for your help.

Web Development – Lean Maintenance of a Website Written in Static HTML

It's a question looking for advice. My / our non-profit website distributing a free pdf manual was launched more than 20 years ago. The site includes about 80 static HTML pages, coded and edited by hand using a text editor, and downloaded via ftp. It's done on OSX.

I would like to simplify the maintenance of html pages to keep them consistent. (The download works well and does not require any special tools.A versioning tool is also not necessary.A large website development system such as Typo3 is also not necessary.)

After 20 years, many software tools appeared that did not exist at the time. What advice would you give to minimize the maintenance of 80 HTML pages? No major redesign and no major extension of the website is planned. At most one page per year is added.

  1. Do you want to continue using an editor? Which?

    1a. An editor that can use HTML snippets?

    1b. An editor who can use HTML includes?

  2. Should I use a template engine? Which of the 200 different?

  3. Should I use a development environment?
  4. Should I use a content management system?
  5. Should we use an online website development tool?

Many people have sent e-mail responses with tips.

The simplest solution, which requires no installation of SW, seems to be 1b, using an HTML editor using the code includes. Alpha is an example of such an editor, available at https://alphacocoa.sourceforge.io/. It also allows you to update an entire folder of HTML files at once, after the includes has been changed.

Code snippets (1a.) Are too simple to be useful. The model / engine editors (2.) are the next possibility and are also useful.

Development environments (3.) are similar to model engines, but generally for other languages, and do not need to be taken into account. CMS (4.) are too heavy. Online tools (5.) are too inflexible.